Gentoo Archives: gentoo-dev

From: Drake Wyrm <wyrm@×××××.com>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] problems with '/usr/sbin/run-crons' on slow computers
Date: Thu, 01 Jul 2004 17:48:24
Message-Id: 20040701174817.GA17931@phaenix.haell.com
In Reply to: [gentoo-dev] problems with '/usr/sbin/run-crons' on slow computers by Alexander Rauth
1 At 2004-07-01T10:19:25+0200, Alexander Rauth <Alexander.Rauth@××××××××××××.de> wrote:
2 > -----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<
3 > mkdir -p /var/spool/cron/lastrun
4 >
5 > # Make sure its not running multiple instances at once.
6 > if test -f /var/spool/cron/lastrun/lock
7 > then
8 > cronpid=`cat /var/spool/cron/lastrun/lock`
9 > if `kill -0 $cronpid >/dev/null 2>&1`
10 > then
11 > exit 0
12 > fi
13 > fi
14 > -----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<
15 > the construction above won't work every time on my K6-200 ....
16 > Once in two days it happens that the 'lock'-file is gone between the
17 > 'test -f ....' and 'cronpid=.....' and I receive following error
18 > message:
19 > -----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<
20 > cat: /var/spool/cron/lastrun/lock: No such file or directory
21 > -----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<
22 >
23 >
24 > if I replace
25 > cronpid=`cat /var/spool/cron/lastrun/lock`
26 > with
27 > cronpid=`cat /var/spool/cron/lastrun/lock 2> /dev/null`
28 > it solves my problem
29 >
30 > My question is, if there is a nicer way to fix that....
31 >
32 > Alexander
33 >
34 >
35 > --
36 > gentoo-dev@g.o mailing list
37
38 It looks as though the Gentoo devs already addressed this issue. You'll
39 need to update sys-apps/cronbase. The fix looks pretty hairy to me. If
40 you want to play with this, I'd start with something like:
41
42 # Make sure its not running multiple instances at once.
43 cronpid=`cat /var/spool/cron/lastrun/lock 2>/dev/null`
44 [ -n "$cronpid" ] && kill -0 $cronpid &>/dev/null && exit 0
45
46 Much cleaner!
47 --
48 Batou: Hey, Major... You ever hear of "human rights"?
49 Kusanagi: I understand the concept, but I've never seen it in action.
50 --Ghost in the Shell