I’m using whm/cpanel and the first time i’m doing a cron job.
I have a php file located in /home/my_website/public_html/wp-content/youtube_channels/cron.php
I want this to run every minute.
I have this as a cron command but i want to make sure it is correct before going forward.
***** /home/my_website/public_html/wp-content/youtube_channels/cron.php
Is this correct? I want this code to run every minute.
2
Answers
For a crontab entry, you need spaces between the stars –
A crontab line
* * * * * php /path/to/phpfile.php >> /path/to/logfile.log 2>&1
* * * * *
time settingsphp
to execute an php file, You can not just call the phpfile like an executeable file (only if you setup and add#!/usr/bin/php
correctly)>>
pipes the output from the phpfile into logfile (or else)/path/to/logfile.log
the log file2>&1
ensures that all what is comeing fromSTDOUT
andSTDERR
is piped into the logfile.More info:
https://corenominal.org/2016/05/12/howto-setup-a-crontab-file/
Run a PHP file in a cron job using CPanel (not only for CPanel user)
http://php.net/manual/en/wrappers.php.php (STDOUT/STDERR)
Have a nice cron