how to simulate a user's crontab?

John Almberg jalmberg at identry.com
Thu Jul 17 11:44:37 UTC 2008


>
> John, it is not a permissions issue, but rather a path issue.
> Do as the other poster suggested and run a cron job to dump the
> environment and you will see that the PATH inside a cron job is very
> rudimentary.  Either add what you need to it in the crontab or cron
> job, or always use absolute paths for everything in a cron entry.
>
> alternatively, set up an AT job as the user, then find the script
> generated by at and grab a copy (/var/spool/cron ???).  You can use
> that copy as the basis for all cron scripts for that user, and always
> have the 'user' environment set up correctly.
>

Yes, I finally figured this out. I had the problem completely  
backwards... I assumed that when I ran 'su user', I was logged in as  
the user. Since the command worked when I was 'logged in' and didn't  
work for crontab, I figured crontab must be different. It never  
occured to me that *I* was running in a different environment :-)

If I had realized, a quick read of the su man page would have solved  
my problem. As it was, I had been shown su long ago by another admin,  
and just assumed I knew how it worked. Wrong!

Well, that's the joys of being of newbie administrator... So little  
time, so many man pages to read!

Thanks: John



More information about the freebsd-questions mailing list