Managing time-triggered events with Zeit

Timetable

© Photo by Matthew Smith on Unsplash

© Photo by Matthew Smith on Unsplash

Author(s):

Zeit offers a graphic front end for the crontab and at tools, making it easier to manage the time-controlled execution of programs, alarms, and timers.

When it comes to managing the time-controlled execution of programs, you can use the entries in the /etc/crontab file (crontab) for repetitive tasks scheduled at regular intervals, or you can use the at command for a one-time action.

While at uses a kind of order book that stores the commands to be executed at a scheduled time, cron works somewhat differently. The crontab contains the entries for the whole system, while the files in /var/spool/cron/crontabs/ contain user-specific entries. Each line in the crontab fully describes a single job. Care must be taken when specifying the jobs because of the entry format's fairly arcane syntax. You can learn this syntax, but it is by no means a trivial task. If you have an LPIC-1 certificate, you will be familiar with the entry format.

Despite care and attention, you may find out that jobs fail to start or are executed at the wrong time. A graphical user interface (GUI) can help reduce errors, even for experienced users. However, several earlier attempts at a suitable GUI for time-controlled calls (e.g., KCron, Kcrontab, CroMagnon, Gnome Schedule [1], Gnome Task Scheduler [2], and VCron) have fallen short with development coming to a standstill.

Zeit [3], a graphic front end for at and crontab, promises to remedy this situation and make managing time-triggered events easier. In development since 2015, Zeit is now considered stable for use and offers both English and Russian versions.

Installation

I tested Zeit v0.6.0 on Debian 11 "Bullseye" without any problems. Currently, Zeit is not included in the official Debian and Ubuntu package sources. However, you can get it via the developer's GitHub repository [4] or an Ubuntu PPA [5].

You have a few options for installing Zeit. You can add the PPA repo by typing apt-add-repository and installing the packages with the package manager (Listing 1). Because this option is not available on Debian, I took the alternative route of deploying the zeit package provided by the developer. After grabbing the package from the project site, I deployed it to the test system using dpkg. There were no dependency problems on other packages. If the package libnotify-bin is missing, you can use apt for the install. When unpacked, Zeit uses about 450KB of disk space.

Listing 1

Installation via a PPA

$ sudo add-apt-repository ppa:blaze/main
$ sudo apt update
$ sudo apt install zeit

If there are no ready-made packages available for your choice of distribution, you can download the source code from the GitHub repository and compile it. I did not test this step, but there is nothing to prevent you from doing so, if necessary. Zeit uses the Qt libraries; you will need to install the associated development packages on your system to build the software.

User Interface

After installation, you'll find Zeit in the Tools section of your application menu. If you use the command-line approach, you can simply call the program by typing zeit. Zeit loads with a clear-cut, functional user interface without any bells and whistles.

In the version I used, the four menu headers are Zeit, View, Tools, and Help. Below the menubar you will find six buttons, some of which you cannot enable until you have selected a job from the list in the main window below.

Using the six buttons, you can add, copy, modify, or delete jobs or commands, and control alarms and timers (Figure 1). Right-clicking on a job opens a context menu where you can Toggle, copy, modify, and delete the selected jobs. Please note that Zeit immediately transfers all changes to the respective crontab or at table. I recommend creating a backup copy of your crontab and at table up front to avoid any nasty surprises later.

Figure 1: Zeit with the daily lunch reminder.

Operating Modes

Zeit launches with normal user authorizations and does not require root access. You can initially only manage your own time-controlled jobs. For system-related jobs, you need to check the box in View | System Mode or press Ctrl+S. You can use the same sequence to switch back to the normal user mode later.

You can also choose Periodic Tasks for crontab, Nonperiodic Commands (one-time jobs) for at, and Environment Variables for cron. You can configure this in the View menu or using the respective Ctrl+P, Ctrl+N, and Ctrl+E keyboard shortcuts. The button labels change to Task, Command, or Variable to indicate this, and you can access the content of the corresponding dialog box for fine-tuning.

The commands for at may require the retroactive installation of the tool; otherwise, your attempts to set up one-time jobs will fail. (You don't have to do this for crontab because cron is typically an essential part of any Linux system and usually installed from the outset.) In Debian GNU/Linux, the package is simply named at. You can install it from the standard package sources using apt.

Adding Tasks

For recurring jobs, either go to Time | Add Task, press the Add Task button, or press Ctrl+A. A dialog box opens where you can then define the new task in more detail (Figure 2). In the upper two input boxes, start by defining the description and the command to be executed.

Figure 2: The entry for lunch at 12 noon from Monday to Friday.

Next, specify the time of execution. Basic allows a simple selection for every minute, hour, day, week, month, or every weekday. Things get more detailed in the Advanced section, where you can specify the exact minute, hour, day, weekday, and month. You can use the same notation as with crontab, for example, 1-5 for Monday to Friday. Context help supports you in your endeavors to correctly specify the individual values.

Below the input boxes, a box tells you what the values you entered actually mean, making it clear when the system will want to execute the task. Note the Enabled checkbox at the bottom: If checked, the task is enabled; otherwise, it will only be added to the table as a comment. Pressing the OK button completes the creation of the new task.

For one-off jobs, the menu item is named Add Command, which opens the matching dialog box in Figure 3. In addition to the description and the command, you need to specify the execution time. Press the Now button to insert the current time, and Reset to reset the input boxes. If you check the box next to Show OSD notification, you will see an additional message on screen ("On-Screen Display") when the command is executed. This helps you keep track of jobs the system executes in the background.

Figure 3: Zeit executes the command to create a one-time backup just before midnight.

Editing Tasks

To edit an existing task, first select an entry in the list and then navigate to Zeit | Modify Task or click on the Modify Task button. Alternatively, you can use the context menu or the Ctrl+M keyboard shortcut. (For one-time jobs, use Modify Command.)

Depending on the task type, the dialog box shown in Figure 2 (recurring task) or Figure 3 (one-time command) appears. The content is the same as when creating a new task. Pressing OK completes the task edit. You can delete an existing task in the same way via Zeit | Delete Task, the Delete Task button, or by pressing Ctrl+D. (For one-time jobs, use Delete Command.)

In addition, you can copy existing tasks via the Zeit | Copy Task menu item or the Copy Task button (one-time tasks use Copy Command). Alternatively, press Ctrl+C to create a copy. Zeit adds the copied task to the end of the task list, where you can now customize it as desired.

Task List

The Zeit GUI offers two possibilities to customize the display in the task list. You can filter the tasks using a search term by either going to View | Show Filter or by pressing Ctrl+F. An input field for the filter text then appears below the task list. Zeit only processes plain text, not regular expressions. Zeit interprets text as case-insensitive and then searches in the description, the execution times, and the stored command.

Another option is a short text display. You can enable this either via View | Shorten Text or by pressing Ctrl+H. In testing, this function had no effect, but maybe the descriptive text I chose was already short enough.

Alarms and Timers

Zeit also allows you to set alarms and timers. You can access the alarms via Tools | Alarm or by pressing Ctrl+L. In the dialog box, you then need to add a description for the alarm, an audio player including the music file to be played, and the times at which you want the alarm to be triggered (Figure 4).

Figure 4: A Zeit alarm can play back sounds with a media player such as VLC.

The Timer dialog box looks almost identical to Figure 4. There is only one additional selection box, labeled Show OSD notification, for a Notification window that controls whether Zeit displays a message on the desktop when the timer expires. You can access the function via Tools | Timer or by pressing Ctrl+T.

Alternatives

If Zeit is not your cup of tea, there are also quite a few web-based tools that at least make it easier to create crontab entries. One candidate, crontab guru [6], lets you first formulate the entry in the web interface and then transfer the results to your system's crontab (Figure 5).

Figure 5: The crontab guru website helps to formulate the crontab entry.

I found the description above the gray input field in crontab guru very helpful because it translates the crontab specification into plain English. The gray field in the middle is an input box where you can edit the value directly, upon which the description changes. Below the input field, you will find explanations for the columns – minute, hour, day, month, and weekday – as well as the values allowed for each column.

Crontab UI [7] is a web front end used primarily for servers. The tool, written in JavaScript (Figure 6), offers extensive options. In addition to the ability to directly edit crontab entries, it provides functions for backing up the crontab and for manually starting, pausing, and terminating jobs.

Figure 6: The web-based Crontab UI is especially useful on servers.

Conclusions

Zeit worked without any issues in testing and integrated cleanly with my system. The entries Zeit generated for crontab and at were also flawless (Figure 7), making it a promising tool for managing the time-triggered jobs.

Figure 7: The crontab table edited with Zeit is free of errors.

The Author

Frank Hofmann works on the road – preferably from Berlin, Geneva, and Cape Town – as a developer, trainer, and author. He is also the co-author of the book Debian Package Management (http://www.dpmb.org/index.en.html).