New user, how to setup cron job?

Status
Not open for further replies.

destin35

New Member
Messages
2
Reaction score
0
Points
1
I have a file that I would like to run at 9:00 am UTC, but im not sure how to set it up. This is the first time I have ever encountered CRONs and have not one clue what to do with it. I don't want to run a bunch of them, just the one once a day.
 

bdistler

Well-Known Member
Prime Account
Messages
3,534
Reaction score
196
Points
63
but im not sure how to set it up
I assume you found the Cron setup icon on the home page of cPanel-x3 theme (not x10hosting Basic theme)

This Cron job will make a 'output' log file in your [ public_html ] folder named [ cron_output.log ] and assumes you PHP script is in your [ public_html ] folder
to test - set the 'time' for every six (6) minutes - I suggest setting it to run no more frequently than you will actually need - after the test
note: the time you set is based on the server's time zone
Code:
Minute -- */6
Hour ---- *
Day ----- *
Month --- *
Weekday --*

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
 

Dead-i

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

The cron job you have already set up will run at 9:05am UTC every day. However, please change the command so that it contains the full path to your script. The path could be /home/destin35/public_html/cron.php, for example.

Thank you,
 

destin35

New Member
Messages
2
Reaction score
0
Points
1
Thank you both for the help.
I went ahead and changed the path for the job and time to let it run every 10 minutes to see what it does.
I get an error when trying to write to a file (part of the script). Is the path of the write relative to where the cron runs or the php file?

:: Edit ::
I think I got it!
$dm_dir = dirname( __FILE__ );
$dm_file = fopen($dm_dir.'/cache/advisors.json','w')
 
Last edited:
Status
Not open for further replies.
Top