Skip to content

Instantly share code, notes, and snippets.

@Twoody
Last active September 17, 2019 23:21
Show Gist options
  • Save Twoody/d08e4aa0b956f004f5cdd35b8209c7c3 to your computer and use it in GitHub Desktop.
Save Twoody/d08e4aa0b956f004f5cdd35b8209c7c3 to your computer and use it in GitHub Desktop.
Example of cron job calling php script to general output /tm/cronOut.txt
#* * * * * /path/to/executable param1 param2
# use /bin/sh to run commands, no matter what /etc/passwd says
SHELL=/bin/sh
# mail any output to `paul', no matter whose crontab this is
MAILTO=tannerleewoody
#Pacific Time (Oregon)
CRON_TZ=PDT
#Out file:
out=/tmp/cronOut.txt
bDir=/var/www/testdir/bash/scripts/
script=everyFifteenSecsExample.sh
# Test every 15 second output
* * * * * $bDir$script
#!/bin/sh
out=/tmp/cronOut.txt
res=/var/www/testdir/bash/resources/
e=test.php
p=$res$e
echo $(whoami) >> $out
echo $(date) >> $out
echo "\t"$(php $p) >> $out
sleep 15;
echo $(date) >> $out
echo "\t"$(php $p) >> $out
sleep 15;
echo $(date) >> $out
echo "\t"$(php $p) >> $out
sleep 15;
echo $(date) >> $out
echo "\t"$(php $p) >> $out
echo "\n" >> $out
<?php
echo "Calling /var/www/testdir/bash/resources/test.php from a bash file\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment