If you’ve used Linux for a while you’ve probably learned about
cron, which is the system service responsible for executing scheduled tasks.
Cron runs in the background, and helps keep your computer running. At scheduled times, it launches programs to rotate log files, check for software updates, and perform other housekeeping jobs. You can also use
cron to your own advantage and to schedule your own tasks; for example, a routine backup of your home directory, or to check if you have new mail. The easiest way to schedule tasks in Ubuntu or Fedora is to use the gnome-schedule application. This tutorial will show you how to schedule tasks using the Gnome Scheduler, a graphical front-end for cron.
First, install the gnome-schedule application. As usual, this is a quick one-liner in most popular distributions:
Ubuntu:sudo apt-get install gnome-schedule
Fedora:sudo yum install gnome-schedule
Once it’s installed, you should see a new “Scheduled Tasks” application in the System Tools menu.
The task scheduler gives you three options for creating a new task. You can chose a recurring task, which is the primary use of gnome-schedule as a frontend for cron. It also allows you to create a task that runs only once; this actually uses the
Additionally, you can create custom schedule templates; for example, if you want to run tasks on certain holidays, you can create a template for that so you don’t have to re-create the cron rules each time. Most users won’t need this feature, but it’s nice to have.
The main window shows you the currently-scheduled tasks:
It’s a bit spartan, and there’s definitely no eye candy, but if you’re at all familiar with cron you’ll be very comfortable with the output.
The primary use of gnome-schedule is to setup cronjobs, and it does it very well. The single-window configuration allows you to specify a name for the job as well as the command to run. The date and time wizard accepts standard cron syntax, but a major feature is a GUI tool that sets up the schedule for you.
For example, by choosing whether you want to run a task every day, every X number of days, or in a range of specific days, you are able to set a schedule with a very high level of precision. This is the precision that
cron is known for, and using gnome-schedule you are able to take this power and implement it via a convenient graphical interface.
Gnome-schedule can create one-time jobs, in addition to recurring tasks. Creating a single-instance job actually uses the
at daemon rather than cron (advanced users should be familiar with the difference, but from our current perspective it doesn’t matter). When you create a one-time job, you get a simple window to give the job a title and a time to launch, and to say what commands you want to run at the scheduled time.
In the above screenshot, I am creating a scheduled task to pop up a reminder window (using Zenity) at 11:55 to tell me that I need to post something to TechThrob (although I assure you, I don’t need any reminders for that). Of course, you can use this for anything — you might want to schedule an alarm to wake you up in the morning, or a reminder to pick something up on the way home.
I find that the single-instance scheduler is actually incredibly useful, perhaps even more useful that the repeating schedule. I never really used
at when it was just a command line utility; I knew it was there, but I didn’t see a need for it. Once I started using gnome-schedule, though, I found that scheduling reminders and automated jobs was very easy and incredibly useful.
The scheduler is incredibly well documented, and you can read the help by clicking the gnome help icon in the main window. I ran into a small problem trying to get graphical applications to launch (zenity, in the above example), but I quickly found the answer in the help (you have to specify the DISPLAY variable). If you’re curious as to how something works, or you’re having some problem, I suggest giving the documentation a look before you get frustrated or ask for help.
Have you ever used cron before? What kind of tasks do you have automated with cronjobs? I’m also curious to know if others find the cron syntax as confusing as I do – I’ve always had to lookup cron syntax when I need to do something more complicated than setting a task to run at a specified minute or hour (hence why I love gnome-schedule’s GUI so much!). Leave your thoughts in the comments below!