Revision as of 13:14, 10 May 2014 by Perspectoff (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Automating Tasks (cron)

  • Cron is a system daemon that runs tasks in the background according to instructions found in a crontab file. To edit the crontab file for the current user:
crontab -e

Tasks that normally require administrative (sudo) privileges should be added to the root user's crontab:

sudo crontab -e

Add commands using the format specified here (or see the Ubuntu Community Help). The crontab command format can also be found using:

man crontab
  • Scheduled/automated tasks (cron events) can also be edited using a KDE GUI interface for cron. Install the configuration module:
sudo apt-get install kde-config-cron
K menu -> System -> System Settings -> Task Scheduler

Example usage

Run ddclient using cron

Cron is the automatic task scheduler for Linux systems. Although ddclient runs as a daemon, for various reasons I have found it necessary to force an update at least once a day. This can be done as a daily scheduled task, using cron. See here for a full description of cron and its options or Ubuntu Community Help.

  • Edit the crontab with administrative (root) privileges:
sudo crontab -e
  • Add the line:
45 04 * * * /etc/init.d/ddclient --force
This will run ddclient and force an update daily at 0400 (actually at 04:45).
  • I also happen to like to reboot the machine weekly on Tuesday (day 2 of the week) nights at 1:30 am, so I add the line:
30 01 * * 2 reboot
Clearly this is a personal preference and is optional.
Force Firefox to quit hourly

A bug in some versions of Firefox allows it to run in the background if not shut down in a certain way. This is a security risk. Cron can be used to forcibly shut down Firefox at a certain time every hour.

  • Edit the crontab with administrative (root) privileges:
sudo crontab -e
  • Add the line:
25 * * * * killall firefox
This will kill Firefox (sudo killall firefox) hourly 25 minutes after the hour (e.g 1:25, 2:25, 3:25, etc.).
Personal tools