Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
One of the things I most like about Linux is that when something goes wrong, you learn something new from it. When something goes wrong on Windows, you learn nothing; ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,197

    You never stop learning!


    One of the things I most like about Linux is that when something goes wrong, you learn something new from it. When something goes wrong on Windows, you learn nothing; it's just a pain in your four letters.

    I have an indexing job that is run every day by cron, but for some reason it wasn't working. Which was odd because there didn't seem to be anything wrong with the script; when I ran it by hand using sudo, it worked well enough.

    I checked to see how cron was doing it. In Crux, cron uses runjobs, equivalent to runparts on some other systems. But that's a simple script too; it just loops through a directory running everything that's executable. Nothing could have gone wrong there surely.

    Then I looked at the other jobs in /etc/cron/daily. One of them was a makewhatis script and that seemed to be working; the timestamp on /usr/man/makewhatis was bang up to date. So I listed the two scripts side by side to see what the difference was, and I found that the makewhatis script (which came with the system) used full pathnames for its commands and my script didn't. I put the pathnames in and now it works.

    I had just assumed that daemons like cron, because they run as root, have access to root environmental variables like $PATH, but seemingly they don't, perhaps because they don't actually log in. You never stop learning.
    "I'm just a little old lady; don't try to dazzle me with jargon!"

  2. #2
    Just Joined! PrinceSharma's Avatar
    Join Date
    Aug 2009
    Location
    /Universe/Earth/India
    Posts
    81
    Like I've just learned a new thing from this post.

  3. #3
    Linux Engineer MASONTX's Avatar
    Join Date
    May 2010
    Location
    Mason Texas
    Posts
    934
    Good job of sleuthing Hazel. Thanks for the report.

  4. #4
    Administrator MikeTbob's Avatar
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    7,864
    Quote Originally Posted by hazel View Post
    One of the things I most like about Linux is that when something goes wrong, you learn something new from it. When something goes wrong on Windows, you learn nothing; it's just a pain in your four letters.

    I have an indexing job that is run every day by cron, but for some reason it wasn't working. Which was odd because there didn't seem to be anything wrong with the script; when I ran it by hand using sudo, it worked well enough.

    I checked to see how cron was doing it. In Crux, cron uses runjobs, equivalent to runparts on some other systems. But that's a simple script too; it just loops through a directory running everything that's executable. Nothing could have gone wrong there surely.

    Then I looked at the other jobs in /etc/cron/daily. One of them was a makewhatis script and that seemed to be working; the timestamp on /usr/man/makewhatis was bang up to date. So I listed the two scripts side by side to see what the difference was, and I found that the makewhatis script (which came with the system) used full pathnames for its commands and my script didn't. I put the pathnames in and now it works.

    I had just assumed that daemons like cron, because they run as root, have access to root environmental variables like $PATH, but seemingly they don't, perhaps because they don't actually log in. You never stop learning.

    Good job detective Hazel! And just for what it's worth,,,,us Crazy Americans only have 3 letters in our "you know what" so it took me a minute to realize what you meant!
    I do not respond to private messages asking for Linux help, Please keep it on the forums only.
    All new users please read this.** Forum FAQS. ** Adopt an unanswered post.

    I'd rather be lost at the lake than found at home.

  5. #5
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    Quote Originally Posted by MikeTbob View Post
    Good job detective Hazel! And just for what it's worth,,,,us Crazy Americans only have 3 letters in our "you know what" so it took me a minute to realize what you meant!
    Good, so I'm not the only one who was stumped by that .

  6. #6
    Linux Engineer MASONTX's Avatar
    Join Date
    May 2010
    Location
    Mason Texas
    Posts
    934
    As Churchill said "We are two nations divided by a common language."

  7. #7
    Linux Newbie
    Join Date
    Apr 2007
    Posts
    214
    I've read once something along the lines that cron does not run on a "bash environment", but something somewhat "poorer". Possibly .bashrc on root's home folder does not even count, as well as other costumary variables like $PATH.

    Once I wanted to have a somewhat more complex program or maybe just even a command to be run by cron, but it wouldn't do it, and then I went looking out for an explanation/solution, that's how I've came to know that, and that's all I remember by now. Perhaps the problem was actually the very same that was described here, just not using explicit paths.
    Openbox + tint2 desktop. Debian testing, liquorix kernel

  8. #8
    Linux Newbie
    Join Date
    Apr 2007
    Posts
    214
    Quote Originally Posted by Cabhan View Post
    Good, so I'm not the only one who was stumped by that .
    I've just read the whole thing, grasping the overall sense from "pain", kept reading, just later as I was reading the other messages I got stumped with these messages relating to the different "you know whats". And I was like "what? What what are they talking about?" Then I've read the first message, maybe two or three times, untill I finally got it.
    Openbox + tint2 desktop. Debian testing, liquorix kernel

  9. #9
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,197
    FYI I've just looked at the cron daemon's environment in /proc/PID/environ. This is what I found:

    CONSOLE=/dev/console
    TERM=linux
    INIT_VERSION=sysvinit-2.86
    PATH=/bin:/usr/bin:/sbin:/usr/sbin
    _=/usr/sbin/crond
    RUNLEVEL=2
    PWD=/
    PREVLEVEL=N
    HOME=/
    SHLVL=2

    So it does have a path but not the same one as root. The indexing program that caused the problem (it's called glimpse) is in /opt/bin, which is the normal location in Crux for user-installed programs, and that's on root's path and mine but not on cron's.
    "I'm just a little old lady; don't try to dazzle me with jargon!"

  10. #10
    Linux Newbie
    Join Date
    Apr 2007
    Posts
    214
    You really never stop learning, I didn't know about the whole "environ" thing. Mine, for debian squeeze/sid is substantially different, I guess:

    LANGUAGE=en_US:en
    CONSOLE=/dev/console
    HOME=/init=/sbin/initrunlevel=2
    INIT_VERSION=sysvinit-2.88
    COLUMNS=160
    TERM=linux
    BOOT_IMAGE=/boot/vmlinuz-2.6.35-0.dmz.1-liquorix-686
    PATH=/sbin:/usr/sbin:/bin:/usr/bin
    RUNLEVEL=2
    PREVLEVEL=N
    LANG=en_US.UTF-8
    SHELL=/bin/sh
    PWD=/previous=NLINES=64TZ=America/Sao_Paulorootmnt=/root
    VERBOSE=noroo


    I don't even now where to split the lines... but I've made bold a line that I think will also make some difference, sometimes, sh instead of bash.
    Openbox + tint2 desktop. Debian testing, liquorix kernel

Page 1 of 2 1 2 LastLast

Posting Permissions

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