[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Start rtorrent on bootup in Squeeze

Nicolas Bercher wrote:
> I can actually see two little cons:
>  1. no "easy way" to stop rtorrent, but that's not a big deal (any
> kill/pkill command could do the job for example, just like my script
> does it),

Or screen -R and press Q or whatever it is.

>  2. since I like to track my scripts & configs, I massively use git
> and/or svn and I really love the "one file per functionnality" way
> of manipulating things.  Via crontab, everything is just mixed up
> into /var/spool/cron/crontabs/<username> and this hard to track and
> even (afaik) to maintain in a quite automatic way.

I keep my user crontabs in ~/.cron/$user/$hostname and only change those
files then feed to cron. This allows keeping them in git and eg, pushing
crontab changes out to machines.

see shy jo
# Construct a crontab based on files in ~/.cron and load it into cron.
# The file ~/.cron/username/fqdn is appended to the common file in the same
# directory. Note that the common file may have "$HOME" in it, as in 
# "PATH=$HOME/bin". cron is too dumb to deal with that, so the expansion is
# handled by this script.
set -e

WARNING="# Automatically generated by loadcron; edit ~/.cron/ files instead."

if [ ! -z "`crontab -l`" ] && ! crontab -l | grep -q "$WARNING"; then
	if [ "$1" != "-f" ]; then
		echo "loadcron: Current crontab was not generated by loadcron; not changing." >&2
		echo "loadcron: Use loadcron -f to override"
		exit 1
		crontab -l > $HOME/tmp/oldcrontab
		echo "loadcron: Old crontab is backed up to $HOME/tmp/oldcrontab"

if [ -d "$dir" ]; then
	hostfile="$dir/`hostname -f`"
		echo "$WARNING"
		if [ -e "$dir/common" ]; then
			echo "# From $dir/common:"
			sed "s!\$HOME!$HOME!" < "$dir/common"
		hostfile="$dir/`hostname -f`"
		if [ -e "$hostfile" ]; then
			echo "# From $hostfile:"
			cat "$hostfile"
	) | crontab -

Attachment: signature.asc
Description: Digital signature

Reply to: