I have this php script that I need to run on shared webhosting. I have created a cron job that executes an sh script. The command for the cron was:
So I'm assuming it is Bourne Shell (or something compatible). The script itself was:
#!/bin/sh cd /home/user/public_html/folder/ #updating DB php -q ./run_interactive_job.php batch_control_files/updateDB echo Updated DB results
My question is:
Can I add Nice priorities to the php command ? Or do I need to add it to the script at the cron command. Which one is more likely to work ?
nice 10 php -q ./run_interactive_job.php batch_control_files/updateDB
Would that be successful at running at a lower priority.
PS: Basically, this script has overloaded the server before when I ran it through the browser and it affected apache on that server resulting in my hosts blocking the file. I have repeatedly asked them unblock to test it with different parameters. And Now I'm trying to run it through cron at a lower priority in the hopes that it won't affect apache. But I don't want it to create issues again, hence I'm trying to use NICE
UPDATE: I used the batch file as shown there. I used the nice command before php inside the batch file. The only difference being:
nice -n 10 php -q ./run_interactive_job.php batch_control_files/updateDB
I added commands to run additional php scripts with the same nice property to them. They all worked great.
THANKS EVERYONE FOR THE INPUT @sm4rk0 answer solves my problems