How do I add Cron jobs in Ubuntu?
Put a shell script in one of these folders:
If these are not enough for you you can add more specific tasks eg. twice a month or every 5 minutes or... go to the therminal and type:
this will open your personal crontab (cron configuration file), the first line in that file explains it all (don't you think)! In every line you can define one command to run, and the format is quite simple when you get the hang of it. So the structure is:
For all the numbers you can use lists eg,
You can also use intervals, they are defined like this:
or every 15 minutes
Note that the day-of-week goes from 0-6 where 0 = sunday.
You can read more here.
If the job you want to run can be run with the same privileges as your user I recommend using a user crontab which you can edit by running
If you want to run something every 10 minutes, for example, you add a line like this
and save the file.
You can see the contents of the user crontab with
The most flexible way is to use the system crontab which you can edit by running
Then if you want to run something every 10 minutes as root, for example, you add a line like this
and save the file.(notice the addition of the user to the line)
You can see the contents of the system crontab file with
More details at: https://help.ubuntu.com/community/CronHowto
If you prefer to do it using a GUI, you can go to the Software Center and install Scheluded tasks. It will provide a powerful GUI to add cron tasks.
Note that if you use this method, tasks by default will be executed as your own user, not as root. This is usually a good thing.
I can recommend KDE's Task Scheduler (
It manages both personal and system Crontabs and especially the ease of creating the time boundaries surprised me (see the screenshot below). I think this part is really underrated.