Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 603460

Summary: sys-process/cronbase: run-crons should recover from bad /var/spool/crontab/lastrun/ state
Product: Gentoo Linux Reporter: Rafal Lalik <rafallalik>
Component: Current packagesAssignee: Cron Team <cron-bugs+disabled>
Status: RESOLVED INVALID    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Rafal Lalik 2016-12-22 12:55:04 UTC
I found a problem with cron tab. After each restart of the computer, the /var/spool/crontab/lastrun directory is missing from the system.

Additionally, in /usr/sbin/run-crons of sys-process/cronbase there is a line 177:

touch "${LASTRUNDIR}"

which causes that a file is created in place of missing directory. It ends up with following error messages in my logs:

touch: cannot touch '/var/spool/cron/lastrun/cron.hourly': Not a directory
touch: cannot touch '/var/spool/cron/lastrun/cron.daily': Not a directory
touch: cannot touch '/var/spool/cron/lastrun/cron.weekly': Not a directory
touch: cannot touch '/var/spool/cron/lastrun/cron.monthly': Not a directory

and it requires manual removal of lastrun file and creation of directory.


My workaround solution is to add a line:

mkdir -p "${LASTRUNDIR}"

just before the touch command mentioned above, but it is always created after the first run-crons calls, so always first time ends up with the error.

Another solution would be maybe to add in line 124 following code:

test -d "{LASTRUNDIR}" || mkdir -p "${LASTRUNDIR}"


I use sys-process/vixie-cron-4.1-r14 and sys-process/cronbase-0.3.7-r6
Comment 1 c.cboldt 2017-01-13 12:56:54 UTC
I am going to guess that this problem is not with cronbase, but with a mixed bag of mounts when cronbase was installed.

If /var/spool/cron/lastrun/ was created on whatever device is mounted root (/), and later, a device is mounted at /var, where that "later device" doesn't have a spool/cron/lastrun directory, your mounts as a whole will show no /var/spool/cron/lastrun/

Show the output of your `df` command.  If there is a mount at /var, or at /var/spool, umount that and check to see if var/spool/cron/lastrun/ was created on the device mounted as "/"
Comment 2 Rafal Lalik 2017-01-13 14:49:46 UTC
Good hit. Now I realized that my /var/spool was on tmpfs. It was old issue related to my SSD disk, I found some advice to put /var/spool on tmpfs, but it doesn't work for Gentoo.