How To Automate Tasks In KDE

KDE provides users with the tools to run software automatically using two features: Autostart and Task Scheduler (formerly called KCron). These tasks can be initiated immediately prior to KDE startup, during KDE startup, or scheduled at anytime: daily, hourly, weekly, or even every five minutes. Both of these features were present in KDE 3. Autostart programs could be dropped into the ~/.kde/share/autostart directory, and automated programs (cron jobs) could be created through a standalone application called KCron.

With KDE 4, Autostart and KCron are now both integrated into System Settings. To start either one, simply click on the K menu and then click System Settings. Next, click the “advanced” tab. Under the Advanced User Settings section, you should see Autostart, and under the System section, make sure that you see Task Scheduler. On my Kubuntu system, Task Scheduler was not installed, so I had to start kpackagekit and install the kcron package.

Running applications at KDE startup

To run an application at KDE startup, follow these simple steps:

  1. In System Settings, click Autostart.
  2. Click Add Program.
  3. Select the application that you want to run (for this example, I will select KRandTray, as it is an application that will start in the system tray).
  4. Click OK.

That is all it takes. You can remove the check from the Enable box anytime you do not want KDE to start with that application.

To run a script on or before KDE startup, follow these simple steps:

  1. Click Add Script.
  2. Type the full path to the script or click the folder to browse your computer for it. (for the example, I am choosing a script I made called startxrandr).
  3. Check or uncheck the Create as symlink box. (If unchecked, it will make a copy of the script in your ~/.kde/share/autostart directory).
  4. Click OK.

Running periodic tasks

Most Unix-like operating systems have a feature that allows the user to run scripts and services on a schedule. For example, if you want a log file to be purged at midnight every night, you can schedule a script to do that. Scheduled tasks are called “cron jobs” because they are handled by a program called Cron, and the schedule is controlled in a configuration file called crontab. In a previous article, MTE taught you how to schedule cron jobs in GNOME. Now, you will learn how to do it in KDE.

To schedule a task in KDE, follow these simple steps:

  1. Open System Settings, click the Advanced tab, and then click Task Scheduler.
  2. Decide whether you want to run a Personal Cron (affecting only your user space) or a System Cron (affecting all users on your system and for which you will need root permissions).
  1. Click New Task.
  2. Enter the command, browse, or begin typing the path (i.e. /usr/bin/), and it will show you a list of commands in that folder in a drop-down menu.
    (For this example, I am selecting a script called that will sync my Google calendar with KOrganizer.)
  3. Next, you simply decide when you want the task to run. Selecting every day will gray out day and month selection, or you can specify a certain month, day, hour, and minute.
    ( For my example, I want it to run every day at 3:30 PM right before I leave work.)
  1. Click OK.

You can also use the Task Scheduler to setup environment variables. In the example image, I have setup one to force KDE into realizing that the system is connected to two monitors (KDE_MULTIHEAD=true).

That is all it takes. With two simple graphical tools, you now have the power to run applications, commands, and scripts whenever and as often as you want.

Tavis J. Hampton

Tavis J. Hampton is a freelance writer from Indianapolis. He is an avid user of free and open source software and strongly believes that software and knowledge should be free and accessible to all people. He enjoys reading, writing, teaching, spending time with his family, and playing with gadgets.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox