How do I set up a Cron job?How to set up a cron job to run every 10 minutes?run script every last thursday of the monthHow to schedule a shell script using crontabEditing crontabCronjob once a day in Ubuntu 12.04How To Run A Shell Script Again And Again Having X Interval Of Time In Root?How to add and modify CRON jobsDaily cron task at certain hour?How to automatically empty trash periodically?What does the last number in the cron time mean?How to run a cron job that relies on .Xauthority?How to remove or delete single cron job using linux command?Running PHP Cron Job with ArgumentsCrontab not run job and change jobHow to run `autopostgresqlbackup` in a cron job?How do I set a cron job for every 5 minutes without using the minutes divisible by 5?cron job not working but works on terminalList what a CRON Job is doing
Why do new jet engines cost billions to design?
How do HK restaurants keep wok-fried scallops white, with no visible sear marks?
Monoids of endomorphisms of nonisomorphic groups
Can a microwave oven make chicken?
Is using RSA with SHA-1 considered as secure as HMAC-SHA-1?
Are there any (natural) scientists in Middle-earth?
In Flanders Fields
Is there a mechanic for a PC to learn the relative strength of an opponent, stat-wise?
What color is a wolf's coat?
How do impulse response guitar amp simulators work?
What can be found in towers of Tower Bridge?
Did any astronauts on a mission complain about waking up?
The lecturer supposed to grade my presentation fell asleep while I held it. Should I complain?
In an interview, is it self-defeating to say you use StackOverflow to find errors in code?
Outside hose bibb with very fine thread?
Single Player Python Battleship Game
What is the maximum distance you can cause damage from?
How can a person Insulate copper wire in a medieval world?
How to deal with third parties in physical pentests?
When does "The Mandalorian" take place?
Single word for being half in this world, half in some other spooky plane of existence
What is the scientific term to describe the operation of a bong?
Isn't it obvious there are infinitely many primes?
Why does Rome municipality seem to have a hard time maintaining the city?
How do I set up a Cron job?
How to set up a cron job to run every 10 minutes?run script every last thursday of the monthHow to schedule a shell script using crontabEditing crontabCronjob once a day in Ubuntu 12.04How To Run A Shell Script Again And Again Having X Interval Of Time In Root?How to add and modify CRON jobsDaily cron task at certain hour?How to automatically empty trash periodically?What does the last number in the cron time mean?How to run a cron job that relies on .Xauthority?How to remove or delete single cron job using linux command?Running PHP Cron Job with ArgumentsCrontab not run job and change jobHow to run `autopostgresqlbackup` in a cron job?How do I set a cron job for every 5 minutes without using the minutes divisible by 5?cron job not working but works on terminalList what a CRON Job is doing
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I want to schedule a task to run on a regular basis and have heard that Cron is the way to do this.
How do I add Cron jobs in Ubuntu?
cron
add a comment
|
I want to schedule a task to run on a regular basis and have heard that Cron is the way to do this.
How do I add Cron jobs in Ubuntu?
cron
add a comment
|
I want to schedule a task to run on a regular basis and have heard that Cron is the way to do this.
How do I add Cron jobs in Ubuntu?
cron
I want to schedule a task to run on a regular basis and have heard that Cron is the way to do this.
How do I add Cron jobs in Ubuntu?
cron
cron
edited Aug 18 '15 at 11:26
Oli♦
233k96 gold badges595 silver badges783 bronze badges
233k96 gold badges595 silver badges783 bronze badges
asked Aug 16 '10 at 8:25
Gabriel SolomonGabriel Solomon
2,9704 gold badges20 silver badges22 bronze badges
2,9704 gold badges20 silver badges22 bronze badges
add a comment
|
add a comment
|
7 Answers
7
active
oldest
votes
Put a shell script in one of these folders: /etc/cron.daily, /etc/cron.hourly, /etc/cron.monthly or /etc/cron.weekly.
If these are not enough for you, you can add more specific tasks e.g. twice a month or every 5 minutes. Go to the terminal and type:
crontab -e
This will open your personal crontab (cron configuration file). The first line in that file explains it all! In every line you can define one command to run and its schedule, and the format is quite simple when you get the hang of it. The structure is:
minute hour day-of-month month day-of-week command
For all the numbers you can use lists, e.g. 5,34,55 in the minutes field will mean run at 5 past, 34 past, and 55 past whatever hour is defined.
You can also use intervals. They are defined like this: */20. This example means every 20th, so in the minutes column it is equivalent to 0,20,40.
So to run a command every Monday at 5:30 in the afternoon:
30 17 * * 1 /path/to/command
or every 15 minutes
*/15 * * * * /path/to/command
Note that the day-of-week goes from 0-6 where 0 is Sunday.
You can read more here.
7
These are system-wide and run with high privileges. I wouldn't put anything there unless there is a pressing need for access or permission. As a rule of thumb, try to do stuff without capabilities. Therefore, I like this answer better: ubuntu.stackexchange.com/questions/2368/how-do-i-setup-cron-job/…
– H Marcelo Morales
Aug 16 '10 at 21:29
5
@Marcelo Morales, Which also will run the given commands as root! if you on the other hand doesn't use sudo then you will create a user crontab and this will be run as the user who created it!
– LassePoulsen
Aug 16 '10 at 21:44
4
*/15 * * * * /path/to/command was very handy for me! thanks!
– Andrew Odendaal
Feb 21 '13 at 11:18
18
It's worth noting these changes are applied automatically, you don't need to restart/reload anything.
– Molomby
Dec 12 '13 at 1:26
6
Another handy tip is that instead of*/15 * * * * /path/to/command, you can do@reboot /path/to/commandin order to execute something on startup.
– Kenneth Worden
Aug 12 '16 at 7:56
|
show 5 more comments
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 EDITOR="gedit" crontab -e (which will use gedit to edit the crontab file) or simply crontab -e (which will use the default editor) in a terminal.
If you want to run something every 10 minutes, for example, you add a line like this
*/10 * * * * /usr/bin/somedirectory/somecommand
and save the file.
You can see the contents of the user crontab with crontab -l.
To add a cron job that runs as root, you can edit root's crontab by running sudo crontab -e.
The most flexible way is to use the system crontab /etc/crontab which you can edit only with root privileges. In this file, the user each command is to be run as is specified, so you can run your commands as root (in case you need that level of privilege) or any other user on the system.
For example, if you want to run something every 10 minutes as root, you'd add a line like this
*/10 * * * * root /usr/bin/somedirectory/somecommand
(notice the addition of the user to the line)
You can see the contents of the system crontab file with cat /etc/crontab.
More details at: https://help.ubuntu.com/community/CronHowto
1
Here's a sweet interactive cron manipulator that will give you the English to the cron time crontab.guru
– CTS_AE
Oct 11 '17 at 9:32
add a comment
|
If you prefer to do it using a GUI, you can go to the Software Center and install Scheduled tasks (or run sudo apt-get install gnome-schedule). 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.
3
not available for 16.04 apparently bugs.launchpad.net/ubuntu/+source/gnome-schedule/+bug/1576060
– TankorSmash
Oct 27 '16 at 22:55
@TankorSmash You can get it here
– M. Becerra
Jan 31 '17 at 22:31
Package requirements can't be met on 16.04
– Odysseus Ithaca
Mar 16 '18 at 16:35
add a comment
|
I recommend KDE's Task Scheduler (kde-config-cron) . Access it from the System Settings in the Task Scheduler module there.
It manages both personal and system Crontabs, and the ease of creating the time boundaries greatly surprised me (see the screenshot below). I think this part is really underrated.

add a comment
|
KDE Task Scheduler will not work in regular Ubuntu. It works only in KDE Systems like KUbuntu. For non KDE system you will prefer to use gnome-schedule
$ sudo apt-get install gnome-schedule
The app is Scheduled tasks in the Dash.
It does not found for Ubuntu 16.04
– SaidbakR
Dec 6 '17 at 17:54
PLease have a look atI can't install gnome schedule on Ubuntu 16.04@ askubuntu.com/questions/785657/…. There is a package to download @ bugs.launchpad.net/ubuntu/+source/gnome-schedule/+bug/1576060/…. Just perform$ sudo dpkg -i gnome-schedule_2.3.0-0ubuntu16.04_amd64.deb
– Antonio
Dec 15 '17 at 20:38
add a comment
|
I wanted to set a Cron job to run through a bash script, so executing the script would add a cron job.
I realised that when you make use of:
crontab -e
Then it creates the file:
/var/spool/cron/crontabs/root
Where root is the name of the user running running the crontab command. So based on this and in 14.04 at least, we can execute the following bash commands to create a new Cron job:
echo "30 17 * * 1 /path/to/command" > /var/spool/cron/crontabs/root
We also need to set the correct ownership for the file:
chown root:root /var/spool/cron/crontabs/root
And set the correct permissions:
chmod 600 /var/spool/cron/crontabs/root
If when you run crontab -e there are already Cron jobs in the list, then you are able append to the list using the following command:
echo "30 17 * * 1 /path/to/command" >> /var/spool/cron/crontabs/root
add a comment
|
Example of running script test_cron.sh by cron every minute on Ubuntu 18.04 using symbolic link:
test_cron.sh file:
#!/bin/bash
echo "System backuped" >> /media/myname/data/backup/backup_tmp.log
If you want to use environment variables in your script like $USER in paths it is better to type precise path, bash will not know your variables at execution time.
myname is user name (part of root group, I am not sure that root privileges are necessary).
Allow users to set cron jobs, file will be created if necessary:
sudo nano /etc/cron.allow
root
myname
The path to script is /home/myname/shell/test_cron.sh
I changed the owner and made it executable:
sudo chown myname /home/myname/shell/test_cron.sh
chmod +x /home/myname/shell/test_cron.sh
I added symbolic link:
sudo ln -s /home/myname/shell/test_cron.sh /usr/bin/test_cron
Logged as myname I added new task to execute test_cron every minute.
crontab -e
*/1 * * * * test_cron
To check if the command in the list:
crontab -l
*/1 * * * * test_cron
To check execution
grep -i cron /var/log/syslog
Nov 17 12:28:01 myname-ubuntu CRON[13947]: (myname) CMD (system-backup)
add a comment
|
protected by Community♦ Apr 11 at 10:16
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
Put a shell script in one of these folders: /etc/cron.daily, /etc/cron.hourly, /etc/cron.monthly or /etc/cron.weekly.
If these are not enough for you, you can add more specific tasks e.g. twice a month or every 5 minutes. Go to the terminal and type:
crontab -e
This will open your personal crontab (cron configuration file). The first line in that file explains it all! In every line you can define one command to run and its schedule, and the format is quite simple when you get the hang of it. The structure is:
minute hour day-of-month month day-of-week command
For all the numbers you can use lists, e.g. 5,34,55 in the minutes field will mean run at 5 past, 34 past, and 55 past whatever hour is defined.
You can also use intervals. They are defined like this: */20. This example means every 20th, so in the minutes column it is equivalent to 0,20,40.
So to run a command every Monday at 5:30 in the afternoon:
30 17 * * 1 /path/to/command
or every 15 minutes
*/15 * * * * /path/to/command
Note that the day-of-week goes from 0-6 where 0 is Sunday.
You can read more here.
7
These are system-wide and run with high privileges. I wouldn't put anything there unless there is a pressing need for access or permission. As a rule of thumb, try to do stuff without capabilities. Therefore, I like this answer better: ubuntu.stackexchange.com/questions/2368/how-do-i-setup-cron-job/…
– H Marcelo Morales
Aug 16 '10 at 21:29
5
@Marcelo Morales, Which also will run the given commands as root! if you on the other hand doesn't use sudo then you will create a user crontab and this will be run as the user who created it!
– LassePoulsen
Aug 16 '10 at 21:44
4
*/15 * * * * /path/to/command was very handy for me! thanks!
– Andrew Odendaal
Feb 21 '13 at 11:18
18
It's worth noting these changes are applied automatically, you don't need to restart/reload anything.
– Molomby
Dec 12 '13 at 1:26
6
Another handy tip is that instead of*/15 * * * * /path/to/command, you can do@reboot /path/to/commandin order to execute something on startup.
– Kenneth Worden
Aug 12 '16 at 7:56
|
show 5 more comments
Put a shell script in one of these folders: /etc/cron.daily, /etc/cron.hourly, /etc/cron.monthly or /etc/cron.weekly.
If these are not enough for you, you can add more specific tasks e.g. twice a month or every 5 minutes. Go to the terminal and type:
crontab -e
This will open your personal crontab (cron configuration file). The first line in that file explains it all! In every line you can define one command to run and its schedule, and the format is quite simple when you get the hang of it. The structure is:
minute hour day-of-month month day-of-week command
For all the numbers you can use lists, e.g. 5,34,55 in the minutes field will mean run at 5 past, 34 past, and 55 past whatever hour is defined.
You can also use intervals. They are defined like this: */20. This example means every 20th, so in the minutes column it is equivalent to 0,20,40.
So to run a command every Monday at 5:30 in the afternoon:
30 17 * * 1 /path/to/command
or every 15 minutes
*/15 * * * * /path/to/command
Note that the day-of-week goes from 0-6 where 0 is Sunday.
You can read more here.
7
These are system-wide and run with high privileges. I wouldn't put anything there unless there is a pressing need for access or permission. As a rule of thumb, try to do stuff without capabilities. Therefore, I like this answer better: ubuntu.stackexchange.com/questions/2368/how-do-i-setup-cron-job/…
– H Marcelo Morales
Aug 16 '10 at 21:29
5
@Marcelo Morales, Which also will run the given commands as root! if you on the other hand doesn't use sudo then you will create a user crontab and this will be run as the user who created it!
– LassePoulsen
Aug 16 '10 at 21:44
4
*/15 * * * * /path/to/command was very handy for me! thanks!
– Andrew Odendaal
Feb 21 '13 at 11:18
18
It's worth noting these changes are applied automatically, you don't need to restart/reload anything.
– Molomby
Dec 12 '13 at 1:26
6
Another handy tip is that instead of*/15 * * * * /path/to/command, you can do@reboot /path/to/commandin order to execute something on startup.
– Kenneth Worden
Aug 12 '16 at 7:56
|
show 5 more comments
Put a shell script in one of these folders: /etc/cron.daily, /etc/cron.hourly, /etc/cron.monthly or /etc/cron.weekly.
If these are not enough for you, you can add more specific tasks e.g. twice a month or every 5 minutes. Go to the terminal and type:
crontab -e
This will open your personal crontab (cron configuration file). The first line in that file explains it all! In every line you can define one command to run and its schedule, and the format is quite simple when you get the hang of it. The structure is:
minute hour day-of-month month day-of-week command
For all the numbers you can use lists, e.g. 5,34,55 in the minutes field will mean run at 5 past, 34 past, and 55 past whatever hour is defined.
You can also use intervals. They are defined like this: */20. This example means every 20th, so in the minutes column it is equivalent to 0,20,40.
So to run a command every Monday at 5:30 in the afternoon:
30 17 * * 1 /path/to/command
or every 15 minutes
*/15 * * * * /path/to/command
Note that the day-of-week goes from 0-6 where 0 is Sunday.
You can read more here.
Put a shell script in one of these folders: /etc/cron.daily, /etc/cron.hourly, /etc/cron.monthly or /etc/cron.weekly.
If these are not enough for you, you can add more specific tasks e.g. twice a month or every 5 minutes. Go to the terminal and type:
crontab -e
This will open your personal crontab (cron configuration file). The first line in that file explains it all! In every line you can define one command to run and its schedule, and the format is quite simple when you get the hang of it. The structure is:
minute hour day-of-month month day-of-week command
For all the numbers you can use lists, e.g. 5,34,55 in the minutes field will mean run at 5 past, 34 past, and 55 past whatever hour is defined.
You can also use intervals. They are defined like this: */20. This example means every 20th, so in the minutes column it is equivalent to 0,20,40.
So to run a command every Monday at 5:30 in the afternoon:
30 17 * * 1 /path/to/command
or every 15 minutes
*/15 * * * * /path/to/command
Note that the day-of-week goes from 0-6 where 0 is Sunday.
You can read more here.
edited Mar 9 '18 at 2:07
community wiki
14 revs, 10 users 51%
LassePoulsen
7
These are system-wide and run with high privileges. I wouldn't put anything there unless there is a pressing need for access or permission. As a rule of thumb, try to do stuff without capabilities. Therefore, I like this answer better: ubuntu.stackexchange.com/questions/2368/how-do-i-setup-cron-job/…
– H Marcelo Morales
Aug 16 '10 at 21:29
5
@Marcelo Morales, Which also will run the given commands as root! if you on the other hand doesn't use sudo then you will create a user crontab and this will be run as the user who created it!
– LassePoulsen
Aug 16 '10 at 21:44
4
*/15 * * * * /path/to/command was very handy for me! thanks!
– Andrew Odendaal
Feb 21 '13 at 11:18
18
It's worth noting these changes are applied automatically, you don't need to restart/reload anything.
– Molomby
Dec 12 '13 at 1:26
6
Another handy tip is that instead of*/15 * * * * /path/to/command, you can do@reboot /path/to/commandin order to execute something on startup.
– Kenneth Worden
Aug 12 '16 at 7:56
|
show 5 more comments
7
These are system-wide and run with high privileges. I wouldn't put anything there unless there is a pressing need for access or permission. As a rule of thumb, try to do stuff without capabilities. Therefore, I like this answer better: ubuntu.stackexchange.com/questions/2368/how-do-i-setup-cron-job/…
– H Marcelo Morales
Aug 16 '10 at 21:29
5
@Marcelo Morales, Which also will run the given commands as root! if you on the other hand doesn't use sudo then you will create a user crontab and this will be run as the user who created it!
– LassePoulsen
Aug 16 '10 at 21:44
4
*/15 * * * * /path/to/command was very handy for me! thanks!
– Andrew Odendaal
Feb 21 '13 at 11:18
18
It's worth noting these changes are applied automatically, you don't need to restart/reload anything.
– Molomby
Dec 12 '13 at 1:26
6
Another handy tip is that instead of*/15 * * * * /path/to/command, you can do@reboot /path/to/commandin order to execute something on startup.
– Kenneth Worden
Aug 12 '16 at 7:56
7
7
These are system-wide and run with high privileges. I wouldn't put anything there unless there is a pressing need for access or permission. As a rule of thumb, try to do stuff without capabilities. Therefore, I like this answer better: ubuntu.stackexchange.com/questions/2368/how-do-i-setup-cron-job/…
– H Marcelo Morales
Aug 16 '10 at 21:29
These are system-wide and run with high privileges. I wouldn't put anything there unless there is a pressing need for access or permission. As a rule of thumb, try to do stuff without capabilities. Therefore, I like this answer better: ubuntu.stackexchange.com/questions/2368/how-do-i-setup-cron-job/…
– H Marcelo Morales
Aug 16 '10 at 21:29
5
5
@Marcelo Morales, Which also will run the given commands as root! if you on the other hand doesn't use sudo then you will create a user crontab and this will be run as the user who created it!
– LassePoulsen
Aug 16 '10 at 21:44
@Marcelo Morales, Which also will run the given commands as root! if you on the other hand doesn't use sudo then you will create a user crontab and this will be run as the user who created it!
– LassePoulsen
Aug 16 '10 at 21:44
4
4
*/15 * * * * /path/to/command was very handy for me! thanks!
– Andrew Odendaal
Feb 21 '13 at 11:18
*/15 * * * * /path/to/command was very handy for me! thanks!
– Andrew Odendaal
Feb 21 '13 at 11:18
18
18
It's worth noting these changes are applied automatically, you don't need to restart/reload anything.
– Molomby
Dec 12 '13 at 1:26
It's worth noting these changes are applied automatically, you don't need to restart/reload anything.
– Molomby
Dec 12 '13 at 1:26
6
6
Another handy tip is that instead of
*/15 * * * * /path/to/command, you can do @reboot /path/to/command in order to execute something on startup.– Kenneth Worden
Aug 12 '16 at 7:56
Another handy tip is that instead of
*/15 * * * * /path/to/command, you can do @reboot /path/to/command in order to execute something on startup.– Kenneth Worden
Aug 12 '16 at 7:56
|
show 5 more comments
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 EDITOR="gedit" crontab -e (which will use gedit to edit the crontab file) or simply crontab -e (which will use the default editor) in a terminal.
If you want to run something every 10 minutes, for example, you add a line like this
*/10 * * * * /usr/bin/somedirectory/somecommand
and save the file.
You can see the contents of the user crontab with crontab -l.
To add a cron job that runs as root, you can edit root's crontab by running sudo crontab -e.
The most flexible way is to use the system crontab /etc/crontab which you can edit only with root privileges. In this file, the user each command is to be run as is specified, so you can run your commands as root (in case you need that level of privilege) or any other user on the system.
For example, if you want to run something every 10 minutes as root, you'd add a line like this
*/10 * * * * root /usr/bin/somedirectory/somecommand
(notice the addition of the user to the line)
You can see the contents of the system crontab file with cat /etc/crontab.
More details at: https://help.ubuntu.com/community/CronHowto
1
Here's a sweet interactive cron manipulator that will give you the English to the cron time crontab.guru
– CTS_AE
Oct 11 '17 at 9:32
add a comment
|
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 EDITOR="gedit" crontab -e (which will use gedit to edit the crontab file) or simply crontab -e (which will use the default editor) in a terminal.
If you want to run something every 10 minutes, for example, you add a line like this
*/10 * * * * /usr/bin/somedirectory/somecommand
and save the file.
You can see the contents of the user crontab with crontab -l.
To add a cron job that runs as root, you can edit root's crontab by running sudo crontab -e.
The most flexible way is to use the system crontab /etc/crontab which you can edit only with root privileges. In this file, the user each command is to be run as is specified, so you can run your commands as root (in case you need that level of privilege) or any other user on the system.
For example, if you want to run something every 10 minutes as root, you'd add a line like this
*/10 * * * * root /usr/bin/somedirectory/somecommand
(notice the addition of the user to the line)
You can see the contents of the system crontab file with cat /etc/crontab.
More details at: https://help.ubuntu.com/community/CronHowto
1
Here's a sweet interactive cron manipulator that will give you the English to the cron time crontab.guru
– CTS_AE
Oct 11 '17 at 9:32
add a comment
|
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 EDITOR="gedit" crontab -e (which will use gedit to edit the crontab file) or simply crontab -e (which will use the default editor) in a terminal.
If you want to run something every 10 minutes, for example, you add a line like this
*/10 * * * * /usr/bin/somedirectory/somecommand
and save the file.
You can see the contents of the user crontab with crontab -l.
To add a cron job that runs as root, you can edit root's crontab by running sudo crontab -e.
The most flexible way is to use the system crontab /etc/crontab which you can edit only with root privileges. In this file, the user each command is to be run as is specified, so you can run your commands as root (in case you need that level of privilege) or any other user on the system.
For example, if you want to run something every 10 minutes as root, you'd add a line like this
*/10 * * * * root /usr/bin/somedirectory/somecommand
(notice the addition of the user to the line)
You can see the contents of the system crontab file with cat /etc/crontab.
More details at: https://help.ubuntu.com/community/CronHowto
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 EDITOR="gedit" crontab -e (which will use gedit to edit the crontab file) or simply crontab -e (which will use the default editor) in a terminal.
If you want to run something every 10 minutes, for example, you add a line like this
*/10 * * * * /usr/bin/somedirectory/somecommand
and save the file.
You can see the contents of the user crontab with crontab -l.
To add a cron job that runs as root, you can edit root's crontab by running sudo crontab -e.
The most flexible way is to use the system crontab /etc/crontab which you can edit only with root privileges. In this file, the user each command is to be run as is specified, so you can run your commands as root (in case you need that level of privilege) or any other user on the system.
For example, if you want to run something every 10 minutes as root, you'd add a line like this
*/10 * * * * root /usr/bin/somedirectory/somecommand
(notice the addition of the user to the line)
You can see the contents of the system crontab file with cat /etc/crontab.
More details at: https://help.ubuntu.com/community/CronHowto
edited Oct 19 '18 at 16:13
Zanna
53.9k15 gold badges150 silver badges253 bronze badges
53.9k15 gold badges150 silver badges253 bronze badges
answered Aug 16 '10 at 8:58
Li LoLi Lo
12.4k4 gold badges31 silver badges38 bronze badges
12.4k4 gold badges31 silver badges38 bronze badges
1
Here's a sweet interactive cron manipulator that will give you the English to the cron time crontab.guru
– CTS_AE
Oct 11 '17 at 9:32
add a comment
|
1
Here's a sweet interactive cron manipulator that will give you the English to the cron time crontab.guru
– CTS_AE
Oct 11 '17 at 9:32
1
1
Here's a sweet interactive cron manipulator that will give you the English to the cron time crontab.guru
– CTS_AE
Oct 11 '17 at 9:32
Here's a sweet interactive cron manipulator that will give you the English to the cron time crontab.guru
– CTS_AE
Oct 11 '17 at 9:32
add a comment
|
If you prefer to do it using a GUI, you can go to the Software Center and install Scheduled tasks (or run sudo apt-get install gnome-schedule). 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.
3
not available for 16.04 apparently bugs.launchpad.net/ubuntu/+source/gnome-schedule/+bug/1576060
– TankorSmash
Oct 27 '16 at 22:55
@TankorSmash You can get it here
– M. Becerra
Jan 31 '17 at 22:31
Package requirements can't be met on 16.04
– Odysseus Ithaca
Mar 16 '18 at 16:35
add a comment
|
If you prefer to do it using a GUI, you can go to the Software Center and install Scheduled tasks (or run sudo apt-get install gnome-schedule). 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.
3
not available for 16.04 apparently bugs.launchpad.net/ubuntu/+source/gnome-schedule/+bug/1576060
– TankorSmash
Oct 27 '16 at 22:55
@TankorSmash You can get it here
– M. Becerra
Jan 31 '17 at 22:31
Package requirements can't be met on 16.04
– Odysseus Ithaca
Mar 16 '18 at 16:35
add a comment
|
If you prefer to do it using a GUI, you can go to the Software Center and install Scheduled tasks (or run sudo apt-get install gnome-schedule). 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.
If you prefer to do it using a GUI, you can go to the Software Center and install Scheduled tasks (or run sudo apt-get install gnome-schedule). 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.
edited Mar 12 '14 at 12:18
Justice for Monica
21.3k14 gold badges60 silver badges122 bronze badges
21.3k14 gold badges60 silver badges122 bronze badges
answered Aug 16 '10 at 9:21
Javier RiveraJavier Rivera
30.9k9 gold badges82 silver badges104 bronze badges
30.9k9 gold badges82 silver badges104 bronze badges
3
not available for 16.04 apparently bugs.launchpad.net/ubuntu/+source/gnome-schedule/+bug/1576060
– TankorSmash
Oct 27 '16 at 22:55
@TankorSmash You can get it here
– M. Becerra
Jan 31 '17 at 22:31
Package requirements can't be met on 16.04
– Odysseus Ithaca
Mar 16 '18 at 16:35
add a comment
|
3
not available for 16.04 apparently bugs.launchpad.net/ubuntu/+source/gnome-schedule/+bug/1576060
– TankorSmash
Oct 27 '16 at 22:55
@TankorSmash You can get it here
– M. Becerra
Jan 31 '17 at 22:31
Package requirements can't be met on 16.04
– Odysseus Ithaca
Mar 16 '18 at 16:35
3
3
not available for 16.04 apparently bugs.launchpad.net/ubuntu/+source/gnome-schedule/+bug/1576060
– TankorSmash
Oct 27 '16 at 22:55
not available for 16.04 apparently bugs.launchpad.net/ubuntu/+source/gnome-schedule/+bug/1576060
– TankorSmash
Oct 27 '16 at 22:55
@TankorSmash You can get it here
– M. Becerra
Jan 31 '17 at 22:31
@TankorSmash You can get it here
– M. Becerra
Jan 31 '17 at 22:31
Package requirements can't be met on 16.04
– Odysseus Ithaca
Mar 16 '18 at 16:35
Package requirements can't be met on 16.04
– Odysseus Ithaca
Mar 16 '18 at 16:35
add a comment
|
I recommend KDE's Task Scheduler (kde-config-cron) . Access it from the System Settings in the Task Scheduler module there.
It manages both personal and system Crontabs, and the ease of creating the time boundaries greatly surprised me (see the screenshot below). I think this part is really underrated.

add a comment
|
I recommend KDE's Task Scheduler (kde-config-cron) . Access it from the System Settings in the Task Scheduler module there.
It manages both personal and system Crontabs, and the ease of creating the time boundaries greatly surprised me (see the screenshot below). I think this part is really underrated.

add a comment
|
I recommend KDE's Task Scheduler (kde-config-cron) . Access it from the System Settings in the Task Scheduler module there.
It manages both personal and system Crontabs, and the ease of creating the time boundaries greatly surprised me (see the screenshot below). I think this part is really underrated.

I recommend KDE's Task Scheduler (kde-config-cron) . Access it from the System Settings in the Task Scheduler module there.
It manages both personal and system Crontabs, and the ease of creating the time boundaries greatly surprised me (see the screenshot below). I think this part is really underrated.

edited Mar 11 '17 at 19:03
Community♦
1
1
answered Jan 31 '13 at 23:59
gertvdijkgertvdijk
53.8k20 gold badges151 silver badges247 bronze badges
53.8k20 gold badges151 silver badges247 bronze badges
add a comment
|
add a comment
|
KDE Task Scheduler will not work in regular Ubuntu. It works only in KDE Systems like KUbuntu. For non KDE system you will prefer to use gnome-schedule
$ sudo apt-get install gnome-schedule
The app is Scheduled tasks in the Dash.
It does not found for Ubuntu 16.04
– SaidbakR
Dec 6 '17 at 17:54
PLease have a look atI can't install gnome schedule on Ubuntu 16.04@ askubuntu.com/questions/785657/…. There is a package to download @ bugs.launchpad.net/ubuntu/+source/gnome-schedule/+bug/1576060/…. Just perform$ sudo dpkg -i gnome-schedule_2.3.0-0ubuntu16.04_amd64.deb
– Antonio
Dec 15 '17 at 20:38
add a comment
|
KDE Task Scheduler will not work in regular Ubuntu. It works only in KDE Systems like KUbuntu. For non KDE system you will prefer to use gnome-schedule
$ sudo apt-get install gnome-schedule
The app is Scheduled tasks in the Dash.
It does not found for Ubuntu 16.04
– SaidbakR
Dec 6 '17 at 17:54
PLease have a look atI can't install gnome schedule on Ubuntu 16.04@ askubuntu.com/questions/785657/…. There is a package to download @ bugs.launchpad.net/ubuntu/+source/gnome-schedule/+bug/1576060/…. Just perform$ sudo dpkg -i gnome-schedule_2.3.0-0ubuntu16.04_amd64.deb
– Antonio
Dec 15 '17 at 20:38
add a comment
|
KDE Task Scheduler will not work in regular Ubuntu. It works only in KDE Systems like KUbuntu. For non KDE system you will prefer to use gnome-schedule
$ sudo apt-get install gnome-schedule
The app is Scheduled tasks in the Dash.
KDE Task Scheduler will not work in regular Ubuntu. It works only in KDE Systems like KUbuntu. For non KDE system you will prefer to use gnome-schedule
$ sudo apt-get install gnome-schedule
The app is Scheduled tasks in the Dash.
answered Feb 11 '14 at 14:35
AntonioAntonio
8462 gold badges11 silver badges18 bronze badges
8462 gold badges11 silver badges18 bronze badges
It does not found for Ubuntu 16.04
– SaidbakR
Dec 6 '17 at 17:54
PLease have a look atI can't install gnome schedule on Ubuntu 16.04@ askubuntu.com/questions/785657/…. There is a package to download @ bugs.launchpad.net/ubuntu/+source/gnome-schedule/+bug/1576060/…. Just perform$ sudo dpkg -i gnome-schedule_2.3.0-0ubuntu16.04_amd64.deb
– Antonio
Dec 15 '17 at 20:38
add a comment
|
It does not found for Ubuntu 16.04
– SaidbakR
Dec 6 '17 at 17:54
PLease have a look atI can't install gnome schedule on Ubuntu 16.04@ askubuntu.com/questions/785657/…. There is a package to download @ bugs.launchpad.net/ubuntu/+source/gnome-schedule/+bug/1576060/…. Just perform$ sudo dpkg -i gnome-schedule_2.3.0-0ubuntu16.04_amd64.deb
– Antonio
Dec 15 '17 at 20:38
It does not found for Ubuntu 16.04
– SaidbakR
Dec 6 '17 at 17:54
It does not found for Ubuntu 16.04
– SaidbakR
Dec 6 '17 at 17:54
PLease have a look at
I can't install gnome schedule on Ubuntu 16.04 @ askubuntu.com/questions/785657/…. There is a package to download @ bugs.launchpad.net/ubuntu/+source/gnome-schedule/+bug/1576060/…. Just perform $ sudo dpkg -i gnome-schedule_2.3.0-0ubuntu16.04_amd64.deb– Antonio
Dec 15 '17 at 20:38
PLease have a look at
I can't install gnome schedule on Ubuntu 16.04 @ askubuntu.com/questions/785657/…. There is a package to download @ bugs.launchpad.net/ubuntu/+source/gnome-schedule/+bug/1576060/…. Just perform $ sudo dpkg -i gnome-schedule_2.3.0-0ubuntu16.04_amd64.deb– Antonio
Dec 15 '17 at 20:38
add a comment
|
I wanted to set a Cron job to run through a bash script, so executing the script would add a cron job.
I realised that when you make use of:
crontab -e
Then it creates the file:
/var/spool/cron/crontabs/root
Where root is the name of the user running running the crontab command. So based on this and in 14.04 at least, we can execute the following bash commands to create a new Cron job:
echo "30 17 * * 1 /path/to/command" > /var/spool/cron/crontabs/root
We also need to set the correct ownership for the file:
chown root:root /var/spool/cron/crontabs/root
And set the correct permissions:
chmod 600 /var/spool/cron/crontabs/root
If when you run crontab -e there are already Cron jobs in the list, then you are able append to the list using the following command:
echo "30 17 * * 1 /path/to/command" >> /var/spool/cron/crontabs/root
add a comment
|
I wanted to set a Cron job to run through a bash script, so executing the script would add a cron job.
I realised that when you make use of:
crontab -e
Then it creates the file:
/var/spool/cron/crontabs/root
Where root is the name of the user running running the crontab command. So based on this and in 14.04 at least, we can execute the following bash commands to create a new Cron job:
echo "30 17 * * 1 /path/to/command" > /var/spool/cron/crontabs/root
We also need to set the correct ownership for the file:
chown root:root /var/spool/cron/crontabs/root
And set the correct permissions:
chmod 600 /var/spool/cron/crontabs/root
If when you run crontab -e there are already Cron jobs in the list, then you are able append to the list using the following command:
echo "30 17 * * 1 /path/to/command" >> /var/spool/cron/crontabs/root
add a comment
|
I wanted to set a Cron job to run through a bash script, so executing the script would add a cron job.
I realised that when you make use of:
crontab -e
Then it creates the file:
/var/spool/cron/crontabs/root
Where root is the name of the user running running the crontab command. So based on this and in 14.04 at least, we can execute the following bash commands to create a new Cron job:
echo "30 17 * * 1 /path/to/command" > /var/spool/cron/crontabs/root
We also need to set the correct ownership for the file:
chown root:root /var/spool/cron/crontabs/root
And set the correct permissions:
chmod 600 /var/spool/cron/crontabs/root
If when you run crontab -e there are already Cron jobs in the list, then you are able append to the list using the following command:
echo "30 17 * * 1 /path/to/command" >> /var/spool/cron/crontabs/root
I wanted to set a Cron job to run through a bash script, so executing the script would add a cron job.
I realised that when you make use of:
crontab -e
Then it creates the file:
/var/spool/cron/crontabs/root
Where root is the name of the user running running the crontab command. So based on this and in 14.04 at least, we can execute the following bash commands to create a new Cron job:
echo "30 17 * * 1 /path/to/command" > /var/spool/cron/crontabs/root
We also need to set the correct ownership for the file:
chown root:root /var/spool/cron/crontabs/root
And set the correct permissions:
chmod 600 /var/spool/cron/crontabs/root
If when you run crontab -e there are already Cron jobs in the list, then you are able append to the list using the following command:
echo "30 17 * * 1 /path/to/command" >> /var/spool/cron/crontabs/root
answered Sep 27 '16 at 20:25
Craig van TonderCraig van Tonder
2881 gold badge3 silver badges14 bronze badges
2881 gold badge3 silver badges14 bronze badges
add a comment
|
add a comment
|
Example of running script test_cron.sh by cron every minute on Ubuntu 18.04 using symbolic link:
test_cron.sh file:
#!/bin/bash
echo "System backuped" >> /media/myname/data/backup/backup_tmp.log
If you want to use environment variables in your script like $USER in paths it is better to type precise path, bash will not know your variables at execution time.
myname is user name (part of root group, I am not sure that root privileges are necessary).
Allow users to set cron jobs, file will be created if necessary:
sudo nano /etc/cron.allow
root
myname
The path to script is /home/myname/shell/test_cron.sh
I changed the owner and made it executable:
sudo chown myname /home/myname/shell/test_cron.sh
chmod +x /home/myname/shell/test_cron.sh
I added symbolic link:
sudo ln -s /home/myname/shell/test_cron.sh /usr/bin/test_cron
Logged as myname I added new task to execute test_cron every minute.
crontab -e
*/1 * * * * test_cron
To check if the command in the list:
crontab -l
*/1 * * * * test_cron
To check execution
grep -i cron /var/log/syslog
Nov 17 12:28:01 myname-ubuntu CRON[13947]: (myname) CMD (system-backup)
add a comment
|
Example of running script test_cron.sh by cron every minute on Ubuntu 18.04 using symbolic link:
test_cron.sh file:
#!/bin/bash
echo "System backuped" >> /media/myname/data/backup/backup_tmp.log
If you want to use environment variables in your script like $USER in paths it is better to type precise path, bash will not know your variables at execution time.
myname is user name (part of root group, I am not sure that root privileges are necessary).
Allow users to set cron jobs, file will be created if necessary:
sudo nano /etc/cron.allow
root
myname
The path to script is /home/myname/shell/test_cron.sh
I changed the owner and made it executable:
sudo chown myname /home/myname/shell/test_cron.sh
chmod +x /home/myname/shell/test_cron.sh
I added symbolic link:
sudo ln -s /home/myname/shell/test_cron.sh /usr/bin/test_cron
Logged as myname I added new task to execute test_cron every minute.
crontab -e
*/1 * * * * test_cron
To check if the command in the list:
crontab -l
*/1 * * * * test_cron
To check execution
grep -i cron /var/log/syslog
Nov 17 12:28:01 myname-ubuntu CRON[13947]: (myname) CMD (system-backup)
add a comment
|
Example of running script test_cron.sh by cron every minute on Ubuntu 18.04 using symbolic link:
test_cron.sh file:
#!/bin/bash
echo "System backuped" >> /media/myname/data/backup/backup_tmp.log
If you want to use environment variables in your script like $USER in paths it is better to type precise path, bash will not know your variables at execution time.
myname is user name (part of root group, I am not sure that root privileges are necessary).
Allow users to set cron jobs, file will be created if necessary:
sudo nano /etc/cron.allow
root
myname
The path to script is /home/myname/shell/test_cron.sh
I changed the owner and made it executable:
sudo chown myname /home/myname/shell/test_cron.sh
chmod +x /home/myname/shell/test_cron.sh
I added symbolic link:
sudo ln -s /home/myname/shell/test_cron.sh /usr/bin/test_cron
Logged as myname I added new task to execute test_cron every minute.
crontab -e
*/1 * * * * test_cron
To check if the command in the list:
crontab -l
*/1 * * * * test_cron
To check execution
grep -i cron /var/log/syslog
Nov 17 12:28:01 myname-ubuntu CRON[13947]: (myname) CMD (system-backup)
Example of running script test_cron.sh by cron every minute on Ubuntu 18.04 using symbolic link:
test_cron.sh file:
#!/bin/bash
echo "System backuped" >> /media/myname/data/backup/backup_tmp.log
If you want to use environment variables in your script like $USER in paths it is better to type precise path, bash will not know your variables at execution time.
myname is user name (part of root group, I am not sure that root privileges are necessary).
Allow users to set cron jobs, file will be created if necessary:
sudo nano /etc/cron.allow
root
myname
The path to script is /home/myname/shell/test_cron.sh
I changed the owner and made it executable:
sudo chown myname /home/myname/shell/test_cron.sh
chmod +x /home/myname/shell/test_cron.sh
I added symbolic link:
sudo ln -s /home/myname/shell/test_cron.sh /usr/bin/test_cron
Logged as myname I added new task to execute test_cron every minute.
crontab -e
*/1 * * * * test_cron
To check if the command in the list:
crontab -l
*/1 * * * * test_cron
To check execution
grep -i cron /var/log/syslog
Nov 17 12:28:01 myname-ubuntu CRON[13947]: (myname) CMD (system-backup)
edited Nov 17 '18 at 10:26
answered Nov 17 '18 at 9:41
AlexanderAlexander
1414 bronze badges
1414 bronze badges
add a comment
|
add a comment
|
protected by Community♦ Apr 11 at 10:16
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?