wellengang.ch

home | projects | about me

Anacron

Anacron lets you schedule scripts for say daily or weekly run without stating the time of the day they should run. This is especially useful if you have a computer that is not running 24/7.

Normally (well, in Ubuntu at least) you put the scripts you want to be run in /etc/cron.daily and anacron is taking care of the the rest. This script get executed as root. This might be a problem if you for example need to have ssh keys involved or just if you are not that comfortable running the script as root.

I solution I found around the web[1][2] works as follows: Create the necessary directories:

mkdir $HOME/.anacron
mkdir $HOME/.anacron/cron.daily
mkdir $HOME/.anacron/cron.weekly
mkdir $HOME/.anacron/timestamps

Where the timestamps directory is used as the spool directory of anacron later. Create the following file $HOME/.anacron/anacrontab with the following content:

# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# These replace cron's entries
1 5 user.daily nice run-parts --report $HOME/.anacron/cron.daily
7 10 user.weekly nice run-parts --report $HOME/.anacron/cron.weekly

# eof

Then add the following line to your $HOME/.profile (to run it automatically each time you log in) or run it manually (each time you login):

/usr/sbin/anacron -t ${HOME}/.anacron/anacrontab -S ${HOME}/.anacron/timestamps &> ${HOME}/.anacron/anacron.log

To have it run like a “normal” anacron task by the system’s anacron I created the following file: /etc/cron.daily/user-anacron :

#!/bin/bash
HOME="/home/USERNAME"
su USERNAME -c "/usr/sbin/anacron -t ${HOME}/.anacron/anacrontab -S ${HOME}/.anacron/timestamps &> ${HOME}/.anacron/anacron.log"

So it is working like a “normal” anacron task.

[1] http://forum.ubuntuusers.de/topic/wie-genau-funktioniert-anacron/

[2] http://ubuntuforums.org/showpost.php?p=4176860&postcount=4.

published on 2011-04-11

Tags: linux debian ubuntu anacron

If you have a NVIDIA card and want to be able quickly enable or disable an external Monitor disper is your friend. (There is also an ubuntu ppa).

You can now simply clone your monitor with disper -c or extend your desktop with disper -e (while the external monitor is connected). Just unplug your monitor again and use the same commands to disable the external monitor.

published on 2011-01-11

Tags: debian ubuntu linux nvidia quicktip

It can't be mentioned enough: Synergy is great. For development I have 3 Computers with 3 different operating systems at work. I don't want to have 3 keyboards or 3 mice, so I am using my Linux box as the host and the Windows 7 and OS X boxes as clients. I can move the mouse pointer seemingless to the left and work on the Windows box and the move it to the right of Linux box to work on the OS X machine.

published on 2010-12-16

Tags: debian ubuntu linux quicktip osx windows

rsync -a /path/to/.[^.]* /path/to
published on 2010-11-25

Tags: linux oneliner quicktip

rm -rf `find . -type f -name <file.name>`
rm -rf `find . -type d -name <directory.name>`
published on 2010-11-19

Tags: linux oneliner quicktip

Next page