I am running a php script though a cronjob using the following :
*/1 * * * * /usr/bin/php -q /home/hduser/Documents/WebCrawl-ProtestData/preg_match.php > /home/hduser/Documents/cronoutput.txt
the script executes every minute and stroes the output in :
is there a way of storing the output in a new file on every run ?
Best How To :
You can put variables into your crontab file and use them in your command:
DATE_STRING =date +%s
*/1 * * * * /usr/bin/php -q /home/hduser/Documents/WebCrawl-ProtestData/preg_match.php > /home/hduser/Documents/cronoutput_$($DATE_STRING).txt
In this case I create a string of the date command and evaluate in the filename (adding an epoch timestamp to the file name)
Note that the initial assignment does not evaluate, as cron is not a shell, but the command line that cron execute does evaluate the string
date +%s when used in the output file name.