skip to Main Content

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


  1. For a crontab entry, you need spaces between the stars –

    * * * * * /home/my_website/public_html/wp-content/youtube_channels/cron.php
    
    Login or Signup to reply.
  2. A crontab line

    * * * * * php /path/to/phpfile.php >> /path/to/logfile.log 2>&1

    • * * * * * time settings
    • php 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 file
    • 2>&1 ensures that all what is comeing from STDOUT and STDERR 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search