Setup scheduled cron tasks
Created by: Reyhan Lange-Kapancioglu
Modified on: Thu, 12 Dec, 2019 at 9:47 AM
You can setup cron tasks by using the crontab tool on our shell server via SSH, this guide will show you how it works.
- Use an SSH client to connect to shell.webinabox.net.au
Windows: You can use the free SSH client PuTTY
Linux, Mac: Open your terminal and run this command: ssh firstname.lastname@example.org
- Enter your username and password, which are the same as your web hosting FTP account
- Once logged in you should be presented with a prompt showing your domain username
testdomain.com@shell:~$View your current crontab entries, if any, using the list command:
testdomain.com@shell:~$ crontab -l
no crontab for testdomain.comOpen your crontab for editing using the edit command
crontab -eThe default editor is an easy to use text editor called Nano, the Ubuntu wiki has information on how to use it: https://help.ubuntu.com/community/Nano. If you prefer to use a different editor, such as vim, you can prefix the crontab command with EDITOR=vim
If you don't have any existing entries, the default file has a quick reminder of the file syntax at the top
# m h dom mon dow command
These columns define the time the job runs, and what command to run. In order, they mean:
day of the month (1-31)
day of the week (0-7) (0 or 7 is Sun)
For each column you can specify a single value, an asterisk ('*') to indicate all possible values, a range of numbers ('8-11') or a comma separated list including both ranges and single numbers ('1-5,7,9').
- Create a new scheduled task by creating a new line below any other existing lines, and specify time you want to run the job followed by the command. Here's an example to run a php script at 6:00 AM every day.
We denote the minute 0, the hour 6, and use an asterisk to match all possible days of the month, months and days of the week.
0 6 * * * php $HOME/public_html/cron.php
Here is another example which runs at 10:30PM Monday - Friday
30 10 * * 1-5 php $HOME/public_html/cron.php
Did you find it helpful?
Sorry we couldn't be helpful. Help us improve this article with your feedback.