Setting up a cron job [[free hosting]]

Status
Not open for further replies.
Messages
48
Reaction score
0
Points
6
I have a php script in <mydomain.com/file.php> which I want to execute every 30 mins. I know cron job is the way to go. I haven't set up cron jobs in the past, can anyone guide me about how to go about it? Like, in the Cron Jobs section of the cpanel, what is the command that I need to give? And what about the Hour, Day, Month, Weekday settings?
 

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
367
Points
83
Hi,

You can set up a cron job from the "Cron Jobs" section of cPanel x3. One of the options in the "Common Settings" dropdown is "Twice Per Hour", which would get executed every 30 minutes. This should be "0,30 * * * *", which means it will run on minute 0 and minute 30 of every hour, every day, every month and every weekday. The command you choose should start with "/usr/local/bin/php", followed by the full path to the script. For example, "/usr/local/bin/php /home/dead-i/cron.php".

Thank you,
 

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
Like, in the Cron Jobs section of the cpanel
be sure to use the [ cPanel-x3 ] theme

what is the command that I need to give?
This Cron job will make a 'output' log file in your public_html folder [ cron_output.log ] and assumes you PHP script is in your public_html folder
to test - set the 'time' for every six (6) minutes

replace {your cPanel name} and {your PHP file name} with yours - without the "{" "}" - do not add any spaces
note: there is a space at [ ...bin/php(space)/home/... ]

cron command - one long line:
Code:
/usr/local/bin/php /home/{your cPanel name}/public_html/{your PHP file name} 2>&1 >> /home/{your cPanel name}/public_html/cron_output.log
 
Status
Not open for further replies.
Top