Last active
September 17, 2019 23:21
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#* * * * * /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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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