Bug 45155 - run-crons and /var/spool/cron/lastrun/lock problems
Bug#: 45155 Product:  Gentoo Linux Version: unspecified Platform: All
OS/Version: Linux Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: agriffis@gentoo.org Reported By: akira@fluxbox.org
Component: Ebuilds
URL: 
Summary: run-crons and /var/spool/cron/lastrun/lock problems
Keywords:  
Status Whiteboard: 
Opened: 2004-03-19 12:33 0000
Description:   Opened: 2004-03-19 12:33 0000
with the default cronbase i get a lot of mail when running vixie-cron, created
by the /usr/sbin/run-crons program/script. basicly it comes from the
lock-mechanism. i did some minor changes to the script and now it runs smoothly
and without any probs as far as i can see.

mail output from unfixed cron-messages:

+----------------------------------------------------------
X-Original-To: root                                                             
Delivered-To: root@localhost
From: Cron Daemon <root@localhost>
To: root@localhost
Subject: Cron <root@localhost> test -x /usr/sbin/run-crons &&
/usr/sbin/run-crons
X-Cron-Env: <SHELL=/bin/bash>
X-Cron-Env: <PATH=/sbin:/bin:/usr/sbin:/usr/bin>
X-Cron-Env: <MAILTO=root>
X-Cron-Env: <HOME=/>
X-Cron-Env: <LOGNAME=root>
Date: Fri, 19 Mar 2004 21:04:00 +0100 (CET)

cat: /var/spool/cron/lastrun/lock: No such file or directory
+----------------------------------------------------------

i ll attach my version. basic problem is imho that another cron-process comes
between the 

[ -f lockfile ]

and the grabbing for the pid out of the lockfile.

regards,
mathias

Reproducible: Always
Steps to Reproduce:
1.
2.
3.

------- Comment #1 From Mathias Gumz 2004-03-19 12:34:05 0000 -------
Created an attachment (id=27641) [details]
new run-crons version

------- Comment #2 From Mathias Gumz 2004-03-19 12:35:31 0000 -------
(From update of attachment 27641 [details])
damn, this is the original :) 

------- Comment #3 From Mathias Gumz 2004-03-19 12:36:38 0000 -------
Created an attachment (id=27642) [details]
new run-crons version

------- Comment #4 From Aron Griffis (RETIRED) 2004-05-06 15:25:31 0000 -------
Created an attachment (id=30876) [details]
better version with non-racy locking

I'll get this in once I actually test it

------- Comment #5 From Aron Griffis (RETIRED) 2004-05-06 15:26:29 0000 -------
Sorry, I'll make sure to add you to the credits too... My code includes some of
your changes.

------- Comment #6 From Aron Griffis (RETIRED) 2004-05-06 15:27:53 0000 -------
Created an attachment (id=30877) [details]
added credit

------- Comment #7 From Mathias Gumz 2004-05-06 20:19:09 0000 -------
works ok so far except for the warning that in line 32 the -lt is syntactilly
wrong ... 

((i=0; i < 2; i=i+1))

should do the trick,

regards,
mathias

------- Comment #8 From Duke 2004-05-16 20:18:46 0000 -------
I'm getting mail with the "kill" usage output:

Usage:                                                                          
  kill pid ...              Send SIGTERM to every process listed.               
  kill signal pid ...       Send a signal to every process listed.              
  kill -s signal pid ...    Send a signal to every process listed.              
  kill -l                   List all signal names.                              
  kill -L                   List all signal names in a nice table.              
  kill -l signal            Convert between signal numbers and names.           

I'm assuming it's because the lockfile doesn't exist, so in run-crons when it gets to the line

if `kill -0 $cronpid >/dev/null 2>&1`

$cronpid is empty, so kill outputs the usage info.  But, shouldn't the line

if test -f /var/spool/cron/lastrun/lock

keep it from getting to that point without a pid?

Is the problem I'm experiencing related to this bug?

------- Comment #9 From Aron Griffis (RETIRED) 2004-05-24 20:55:37 0000 -------
Ok, it's in portage as cronbase-0.3.  And yes Duke, this should solve the
problem you described.

------- Comment #10 From Duke 2004-05-24 20:58:46 0000 -------
Thank you!