I basically have a cron job which runs every night that updates thousands of products in my database.
The reason I run the cron job at night is because there will be less latency on the servers as not many people visit the site during this time, the cron job can pretty much run on for days without any interference.
Here is what the cron job command looks like
30 23 * * * /usr/bin/php /var/www/ul/prices_all.php >> /var/www/ul/log/prices_all.txt
What I would like to know is would it be possible to create a cron job which kills this process after 5 hours e.g.
30 05 * * * kill /var/www/ul/prices_all.php[process]
You can do this with timeout (coreutils):
It simply sets a timeout (18000secs = 5 hours) and kills the process if it is still running after that time.
Or you can set a timeout in the php file itself: