Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Jul 2008 07:44:33 -0400
From:      John Almberg <jalmberg@identry.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: how to simulate a user's crontab?
Message-ID:  <6155B532-19E5-473C-9736-6C7BFBD3E1FE@identry.com>
In-Reply-To: <487F1097.31417.718F23E@iwrtech.iwr.ru.ac.za>
References:  <487F1097.31417.718F23E@iwrtech.iwr.ru.ac.za>

next in thread | previous in thread | raw e-mail | index | archive | help
>
> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6155B532-19E5-473C-9736-6C7BFBD3E1FE>