cronjob in cron.d appears not to run

You have a problem with Salix? Post here and we'll do what we can to help.
Post Reply
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

cronjob in cron.d appears not to run

Post by mimosa »

I'm experimenting with lockout, which worked fine under Ubuntu:

http://www.linux.com/archive/feature/116324

Basically it temporarily scrambles your root password and then obeys your settings to block various time wasting activities. As the author points out, in principle this is risky, but I was careful. After the time you set expires, all returns to normal when the program executes this in /etc/cron.d

Code: Select all

# lockout needs to check every minute whether it's time to unlock
*/1 * * * *	root	/usr/bin/lockout unlock >/dev/null 2>&1

# rebooting *MUST* restore the root password
@reboot	        root	/usr/bin/lockout unlock force >/dev/null 2>&1
However, it doesn't work. Googling threw up a number of reports from people using various distros about things they put in cron.d not running as expected.

Any ideas as to why this might be and how to fix it?

Needless to say, I haven't tested the second active line beginning @reboot.
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: cronjob in cron.d appears not to run

Post by mimosa »

I put the two lines in the crontab but removed the user specification "root", and it seems to work - it doesn't work if I put root back. The app is always called as root to set up the temporary restrictions. Not sure if the @reboot line should have it, though.

To sum up, the problem doesn't seem to be with the location of the file in /etc/cron.d, but with the specification of the root user. However, it is not possible to edit the default file to test this definitively, because lockout runs a check to see it contains the lines it thinks it should and refuses to run if not.

Although everything is now working as expected, I don't think I can trust it without understanding better why. In particular, I suppose that @reboot line is important if the dog yanks the power line out of the wall at the wrong moment. As it is presumably no longer being run as a child process of lockout (and therefore definitely root), I'm not sure about it.
Post Reply