php - Having Cron job execute script in background and run for 15 hours -
i have php script takes 15 hours run , have run once week. script downloads , extracts contents of massive (70gb) csv file our database.
i need script start running every sunday @ 6 pm , keep running until it's finished processing file.
my plan create bash file cron.sh has following:
nohup php /var/www/html/cron.php > /var/www/html/outputs/`date "+%y-%m-%d %h:%m:%s"`.log and cron being:
0 18 * * 0 /var/www/html/cron.sh how able improve this?
remember redirect stderr well:
nohup php /var/www/html/cron.php > dir/stdout.log 2> dir/stderr.log or if prefer merge them in same file:
nohup php /var/www/html/cron.php > dir/stdout.log 2>&1 the 2>&1 means redirect stderr same file stdout using.
the rest fine, putting command inside shell script makes more readable if line long. if later want make task more things, easier update script file.
i rename cron.sh file more meaningful.
Comments
Post a Comment