how to simulate a user's crontab?

Bill Moran wmoran at potentialtech.com
Wed Jul 16 15:38:13 UTC 2008


In response to John Almberg <jalmberg at identry.com>:

> I often run into permission problems with user crontabs. That is, a  
> crontab run under a user's permissions.
> 
> First of all, it seems to me that a user's crontab doesn't have  
> exactly the same permission as the user himself. Is this true?

The crontab runs as the user, and thus has the exact same permissions.

> Is there anyway I can simulate these permissions on the command line,  
> so I can test things before putting them in a crontab?
> 
> What I'd like to avoid is the frustrating cycle of putting a line in  
> a user's crontab (a few minutes ahead), waiting for it to fire off,  
> have it fail, check error logs, try again...
> 
> It would be much simpler if I could simulate the crontab's  
> environment, and just run the thing from the command line.
> 
> Any hope? I'm running FreeBSD 6.3

I'm guessing you're having problems with environment settings, although
the vagaries of the question don't give me much to go on (something
along the lines of, "when I try to do x in cron, I get the error y;
but it works fine when the user runs it outside of cron" would be more
informative.)

Write a cron job to dump the cron environment via echo, you can then
set those environment variables when testing your scripts.

-- 
Bill Moran
http://www.potentialtech.com


More information about the freebsd-questions mailing list