You are not logged in.

#1 2009-04-16 01:37:32

Xiong Chiamiov
Member
From: central coast, california
Registered: 2008-06-18
Posts: 142
Website

cron doesn't execute script until restarted

I wrote a script to change my wallpaper, and placed it in /etc/cron.hourly.  It will not run on the hour, or any time, after starting my computer.  However, if I restart cron, then everything is fine.  run-parts indicates that it *should* run:

┌─[pearson@pearson-arch] - [~] - [Wed Apr 15, 06:33]
└─[$]> sudo run-parts --test /etc/cron.hourly 
Password: 
/etc/cron.hourly/adjtime
/etc/cron.hourly/rotate_background
┌─[pearson@pearson-arch] - [~] - [Wed Apr 15, 06:33]
└─[$]>

Just to make sure, cron *is* started on system boot.

Offline

#2 2009-04-25 18:22:47

Xiong Chiamiov
Member
From: central coast, california
Registered: 2008-06-18
Posts: 142
Website

Re: cron doesn't execute script until restarted

Bump because it really bothers me not knowing the cause of this behavior.

Offline

#3 2009-04-26 23:43:13

thisllub
Member
From: Northern NSW Australia
Registered: 2007-12-28
Posts: 231

Re: cron doesn't execute script until restarted

What does the cron log say?
Arch seems to use run-cron not run parts.
Does the script have executable permissions?
If a script runs as root user it may not have access to your desktop variables (not sure about this)
Does it work if you install it from you own crontab?

Offline

#4 2009-04-27 00:35:49

Xiong Chiamiov
Member
From: central coast, california
Registered: 2008-06-18
Posts: 142
Website

Re: cron doesn't execute script until restarted

thisllub wrote:

What does the cron log say?

It doesn't mention it.

thisllub wrote:

Arch seems to use run-cron not run parts.

Run-parts allows you to specify a certain folder to run; it has a --test option, which run-cron doesn't seem to have.

thisllub wrote:

Does the script have executable permissions?

755, owned by root:root, which is the same as the other script in that folder (adjtime, which I think might be part of ntpd).

thisllub wrote:

If a script runs as root user it may not have access to your desktop variables (not sure about this)

The odd thing is that it runs fine once I restart cron.  I was using /usr/bin/env in the hash-bang, though, so I've changed that, and I'll see if that changes anything.

thisllub wrote:

Does it work if you install it from you own crontab?

I... don't really know how to do that yet.  I'll have to look it up and get back to you.

Offline

#5 2009-08-25 15:31:28

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: cron doesn't execute script until restarted

I expect the script is being run, but just isn't producing the desired results, perhaps because it's expecting some environment variables to be defined which aren't defined in the cron environment. I would get rid of /usr/bin/env in your hash-bang, and just after that add a line like

date >> /home/mysuer/test_cron

just to check if the script is being executed. You could also try stopping the /etc/rc.d/crond service, and instead running

sudo crond -d

from a terminal, just to make sure that the /etc/cron.hourly line in your crontab is being called.

Using run-parts instead of run-cron is fine.

Offline

Board footer

Powered by FluxBB