Results 1 to 7 of 7
As some of you may know I've been fighting a problem. But here I want to ask a question. We are running Suse9 sp3.
I submit a cmd through cron( ...
- 10-31-2007 #1Linux Newbie
- Join Date
- Jun 2006
- Posts
- 139
cron and root env question
As some of you may know I've been fighting a problem. But here I want to ask a question. We are running Suse9 sp3.
I submit a cmd through cron( env > /tmp/env.log) to show me the crontab env and here it is:
SHELL=/bin/sh
PATH=/usr/bin:/bin
PWD=/root
SHLVL=1
HOME=/root
LOGNAME=root
_=/usr/bin/env
Is it truely showing me crontabs env????
The reason I ask is because in /etc/crontab I changed the path to:
PATH=/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/java/bin:/home/lit2/sqllib/bin:/home/lit2/sqllib/adm:/home/lit2/sqllib/misc
Why am I not seeing this path??
thanks
Mace
- 10-31-2007 #2
Yes, that looks a lot like a cron environment.
In /etc/crontab, try export PATH=blah:blah:blah
- 10-31-2007 #3Linux Newbie
- Join Date
- Jun 2006
- Posts
- 139
But I don't have any dir named blah....

Thanks for the info ..I'll give it a try
mace
- 10-31-2007 #4Linux Newbie
- Join Date
- Jun 2006
- Posts
- 139
put export in but still have the same results:
SHELL=/bin/sh
PATH=/usr/bin:/bin
PWD=/root
SHLVL=1
HOME=/root
LOGNAME=root
_=/usr/bin/env
thanks
Mace
- 10-31-2007 #5
Hmm. I just reviewed my /etc/crontab and found that the export is not necessary after all.
I ran a little test and this is what I found: setting PATH in /etc/crontab only appears to update the PATH for cronjobs called specifically from /etc/crontab.
If you have a cronjob running from a user crontab (i.e. modified via crontab -e), then you can either add the PATH assignment directly into the user crontab or into the script itself.
Make sense?
- 10-31-2007 #6Linux Newbie
- Join Date
- Jun 2006
- Posts
- 139
I added the path(export PATH=xxxxx) into the script and the same problem occurred. I (root) has a classpath in its env. Iwas going to add. I've looked around but can't see an exact method of doing that. Should I just put classpath=xxx or should I export it??
thanks
Mace
- 10-31-2007 #7
My export comment was ill-advised and unnecessary. You can forget about using export unless you're going to need a child process (script) to inherit the variable values.
What you're describing doesn't make sense. You're explicitly adding a PATH declaration into your script, and then when you echo its contents they're no longer there?
Maybe you could post the script or relevant snippets of it. I'd also suggest just echoing the variable to stdout (which means the user's email, when run from cron) rather than to a temporary file.


Reply With Quote
