Running PHP with Crontab

software development

#1

I’ve read up on the wiki about using crontab to run PHP scripts at set times. I guess I don’t exactly understand the DH wiki, and so with some websearching came up with some stuff, but don’t know if it works with DH because of the shared hosting. Is the following line proper to execute a PHP script at midnight each sunday? Is it also important to note that I have my own copy of PHP running so I can modify my .ini file, that I set up using the directions on the DH wiki.

0 0 * * 0 php /home/site/folder/script.php

and put

#!/usr/local/bin/php -q

at the top of the PHP script?


#2

you will need to provide full path of your PHP binary files.

So it will be 0 0 * * 0 /usr/local/bin/php /home/site/folder/script.php

$50 off and 3 free domains with code: [color=#CC0000]DH3[/color] Sign Up NOW or More Codes Here


#3

Is “usr” static? Or should I put in the actual user name? And just to confirm, this doesn’t change whether I use the PHP when setting up an account/domain or if I setup my own PHP for a custom .ini?


#4

usr is static. It is same for all the servers. It is not your username but a default folder set up by DH.

If you are not sure about PHP path, you can type command “which php”.

If you setup your own PHP, you should give the path of your own PHP like /home/username/php/php (sample)

$50 off and 3 free domains with code: [color=#CC0000]DH3[/color] Sign Up NOW or More Codes Here