Gentoo Archives: gentoo-user

From: "Boyd Stephen Smith Jr." <bss03@××××××××××.net>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Sync and glsa-check from cron
Date: Tue, 19 Jun 2007 23:40:01
Message-Id: 200706191834.19587.bss03@volumehost.net
In Reply to: Re: [gentoo-user] Sync and glsa-check from cron by Joshua Doll
1 On Tuesday 19 June 2007 17:26:15 Joshua Doll wrote:
2 > Nick wrote:
3 > > I can set up the sudoers part all fine, but is there anything I
4 > > should watch out for / consider when running these maintenance tools
5 > > from a cron job?
6
7 Oh, and I forgot to mention it in my other direct reply: You'll probably need
8 to specify the full path to those commands. $PATH is generally different or
9 unset when tasks are run from cron.
10
11 > I think cron can run jobs as root.
12
13 Yes, /etc/cron.{hourly,daily,weekly,monthly} contains scripts to be run as
14 root. Also, some (most? all?) cron daemons allow root to have a crontab
15 separate from the system crontab. If you have root access you can even
16 fiddle with the system crontab, but that's not the "preferred" solution.
17
18 Many cron daemons also allow jobs to be run as a user by maintaining a crontab
19 for each user and "su"-ing to the correct user (and cleaning/setting the
20 environment) before running the task. If I'm reading the question correctly,
21 he will be adding these actions to his user's crontab and then sudo-ing to
22 run the script. sudo can be set up to allow users to run tasks as root
23 without a password. sudo also cleans the environment by default, but that
24 can be turned off or made less strict.
25
26 However, tasks run by cron (either as root or as another user) will have
27 different environment variables set. e.g. /etc/profile and $HOME/.profile
28 are not sourced in the shell (generally cron jobs aren't run in a shell at
29 all). They will also generally not have a tty associated with them. Again,
30 if I'm reading the OP correctly, (s)he was wondering if those changes will
31 affect those two commands. Some commands / scripts are quite sensitive to
32 the environment and may give different results (or not work at all) when run
33 from a cron job.
34
35 --
36 Boyd Stephen Smith Jr. ,= ,-_-. =.
37 bss03@××××××××××.net ((_/)o o(\_))
38 ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
39 http://iguanasuicide.org/ \_/

Attachments

File name MIME type
signature.asc application/pgp-signature