On Tuesday 19 June 2007 17:26:15 Joshua Doll wrote:
> Nick wrote:
> > I can set up the sudoers part all fine, but is there anything I
> > should watch out for / consider when running these maintenance tools
> > from a cron job?

Oh, and I forgot to mention it in my other direct reply:  You'll probably need 
to specify the full path to those commands.  $PATH is generally different or 
unset when tasks are run from cron.

> I think cron can run jobs as root.

Yes, /etc/cron.{hourly,daily,weekly,monthly} contains scripts to be run as 
root.  Also, some (most? all?) cron daemons allow root to have a crontab 
separate from the system crontab.  If you have root access you can even 
fiddle with the system crontab, but that's not the "preferred" solution.

Many cron daemons also allow jobs to be run as a user by maintaining a crontab 
for each user and "su"-ing to the correct user (and cleaning/setting the 
environment) before running the task.  If I'm reading the question correctly, 
he will be adding these actions to his user's crontab and then sudo-ing to 
run the script.  sudo can be set up to allow users to run tasks as root 
without a password.  sudo also cleans the environment by default, but that 
can be turned off or made less strict.

However, tasks run by cron (either as root or as another user) will have 
different environment variables set.  e.g. /etc/profile and $HOME/.profile 
are not sourced in the shell (generally cron jobs aren't run in a shell at 
all).  They will also generally not have a tty associated with them.  Again, 
if I'm reading the OP correctly, (s)he was wondering if those changes will 
affect those two commands.  Some commands / scripts are quite sensitive to 
the environment and may give different results (or not work at all) when run 
from a cron job.

-- 
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
[EMAIL PROTECTED]                      ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.org/                      \_/     

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to