Setting up CRON jobs from the command line/terminal is relatively easy but if you’re hosting on a shared server or entry level server you might not get SSH access. It might be the case that you have a section in your hosting control panel to do this for you via an editor or a form. If you do have SSH access, these are the commands you need:

To list current CRON jobs

crontab -l” (That’s L for LIST not i)
…this will show you the current cron jobs in your config file for your user account.

Each line of this config file is a “cron job”, a cron job’s make up for each line is as follows:
minute hour day-of-month month day-of-week command

To “Edit” type or create when list fails

crontab -e
…this will open your personal (logged in account) cron configuration. This will launch vi (editor) for the config file. If it’s empty you’ll see loads of blank lines denoted by tild symbols ‘~’. vi help commands here: https://www.cs.colostate.edu/helpdocs/vi.html

To “Remove” type

crontab -r
…this will remove your cronjobs (all of them!)

To “Remove just one” type

crontab -e
…this will load the editor, then just remove the cron job line you want to remove/disable

Real world example line

01 04 * * * /usr/bin/somedirectory/somecommand
That will run at 0401 (AM, as it’s 24hr clock) every day.
01=minute
04=hour
Next 3 * (day/month/year)
/usr/bin…=command to run.

You can use string formatted jobs with these @keywords:
[Legend, string = meaning]
@reboot = Run once, at startup.
@yearly = Run once a year, “0 0 1 1 *”.
@annually = (same as @yearly)
@monthly = Run once a month, “0 0 1 * *”.
@weekly = Run once a week, “0 0 * * 0”.
@daily = Run once a day, “0 0 * * *”.
@midnight = (same as @daily)
@hourly = Run once an hour, “0 * * * *”.
…if you choose to use @keyword timeouts then your cron line would look like this:
“@reboot /path/to/execuable1”
…this would execute on reboot of the system and execute the path to executable1

NOTE

Your biggest challenge with a cron job is creating a stand alone PHP script (or executable) that can run from the terminal/command line. You can test that anytime by creating your script in a saved file called “cron-script.php”, then at the command line/terminal type “php cron-script.php”. Your PHP will execute and anything in the output buffer will be printed to the screen. REMEMBER(!) a cron job runs in the background so you won’t see ANY output. Only use output to test when launching manually.

That’s it…happy scheduling!