Find the answer to your Linux question:
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( ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Jun 2006
    Posts
    141

    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

  2. #2
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    Yes, that looks a lot like a cron environment.

    In /etc/crontab, try export PATH=blah:blah:blah

  3. #3
    Linux Newbie
    Join Date
    Jun 2006
    Posts
    141
    But I don't have any dir named blah....
    Thanks for the info ..I'll give it a try
    mace

  4. #4
    Linux Newbie
    Join Date
    Jun 2006
    Posts
    141
    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

  5. #5
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    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?

  6. #6
    Linux Newbie
    Join Date
    Jun 2006
    Posts
    141
    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

  7. #7
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •