Scheduling Tasks in Linux
Like all operating systems, Linux keeps track of the time and date, and this makes it possible to schedule tasks to run at particular times – either on a one-off basis or regularly at specified intervals. The most obvious candidate for this is a backup process, but it can also be used to set up overnight downloads, when bandwidth rates are cheaper.
The underlying daemon which takes care of scheduled tasks is called ‘cron’, and it is possible to set cron tasks directly via the crontab -e command. This should dump you in a text file where new tasks can be added to a list. Unfortunately, the syntax is a little intimidating and the default editor is the primitive vi system, which makes it all more difficult than it should be. Luckily, a couple of graphical front-end programs have been developed to improve the user experience.
The first of these calls itself ‘Scheduled Tasks’, though its command-line name is gnome-schedule. It can be installed through the Add/Remove option on the Applications menu, and it has a nice friendly interface. The only problems were, I couldn’t get it to add any new tasks unless I logged on as root, and once the tasks were added it wouldn’t run them. Keen users may be able to tinker with it and make it work, but I gave up and downloaded an alternative programme designed for KDE called KAlarm.
KAlarm in operation
Most KDE programs run under GNOME without any problems whatsoever. KAlarm is one of the exceptions. When first started it takes over the screen, and you may have to select ‘Exit’ from the File Menu to get access to your taskbars and icons again. Even then it still shows up without a title bar or window boundaries. That doesn’t really matter, though, because all you have to do is to set up your scheduled tasks and then minimise KAlarm out of the way.
There are three kinds of ‘alarms’ – i.e. scheduled tasks – that KAlarm can set:
- Text Alarms, which simply pop up a text box at a specified time with a reminder – ‘Meeting with Sam at 2:00’, for instance.
- Email Alarms, which will send off a pre-addressed email at a specified time. Unfortunately this only works with the KDE email programs Sendmail and Kmail, but if you have one of those installed you should be able to use this feature.
- Command Alarms, the heart of the system, which allows the user to schedule either a single command – e.g. ‘backup’ – or a complete bash script. This gives the user complete control over what is run and when.
One-off alarms can be set to run once, at a specified time, or at a specified length of time from now. Recurring alarms can be set to run every minute, every hour, every day, or at any other interval – on the 2nd Saturday of each month, for instance. There’s even an option to run them during working hours only. Alarms that you use frequently can be saved as templates and called up when a new instance is needed. Settings option include keyboard shortcuts and toolbar displays, as well as an option to start at login time. The user can add a beep or other sound file to alarms and set various other options relating to the appearance of the alarms and the program display.
When minimised, KAlarm appears as a clock icon in the system tray. Hovering the mouse pointer over the icon is supposed to show a list of current alarms, but this may be a KDE feature that doesn’t work in Ubuntu. Apart from this and the minor problem with a title bar and window borders, KAlarm worked smoothly and did exactly what it was supposed to.