Find the answer to your Linux question:
Results 1 to 10 of 10
Hi guys, looking for some help. I try to execute a cron task which calls a .sh file. And this .sh file calls another .sh file. When I run automatically ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2005
    Location
    France
    Posts
    6

    Cron task


    Hi guys,

    looking for some help. I try to execute a cron task which calls a .sh file. And this .sh file calls another .sh file.
    When I run automatically the task, the content of the first .sh file is executed but not the second. But if I run manually the task from the webmin interface, everything runs alright.
    Just for testing, I've put a lot of chmod and chown as root and set the cron task to run as root.
    Can anybody tell me why the adduser command of the second .sh file is not executed when automatic but is executed when manual?

    Thanks for your help

    Axel

  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    Put an echo statement at the very top of the second script. Then execute it via the cron job.

    I'm curious if there is simply some funky issue from the cron job, or if the second script really isn't being called at all.

  3. #3
    Just Joined!
    Join Date
    Nov 2005
    Location
    France
    Posts
    6
    The thing is: if I run the cron manually, that works, and if I run it automatically, I'm not gonna be able to see the echo...

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Nov 2005
    Location
    France
    Posts
    6
    Called by the Cron task:
    Code:
    chown root:root /var/www/admin/input.sh
    chmod 777 /var/www/admin/input.sh
    /var/www/admin/input.sh
    rm /var/www/admin/input.sh
    and now input.sh
    Code:
    mkdir /home/ftp/test
    useradd -d /home/ftp/test -e 2005-11-2 -g ftpusers -G ftpusers -p aXfy7VeuS4T1s -s /bin/false test
    chown ftpupX:ftpusers /home/ftp/test
    chmod g=rwx /home/ftp/test

  6. #5
    Just Joined!
    Join Date
    Nov 2005
    Location
    France
    Posts
    6
    Actually, in the automatic execution of Cron, every single line is executed but the useradd. The new folder is created and the new permissions on it are updated.

    I do not understand why this useradd command is not read properly.

    Thanks,

    Axel

  7. #6
    Just Joined!
    Join Date
    Nov 2005
    Posts
    1
    - just a guess
    Try to give the full path to useradd. I suppose i'ts a environment issue

  8. #7
    Linux Newbie
    Join Date
    Nov 2004
    Location
    New York
    Posts
    150
    Without knowing anything substantial about either cron or useradd, I would guess that the problem has to do with useradd knowing that it's not being executed with a tty as stdout, and modifying its behavior accordingly. Perhaps it mentions something about that in the man pages?
    \"Nifty News Fifty: When news breaks, we give you the pieces.\" - Sluggy Freelance

  9. #8
    Just Joined!
    Join Date
    Nov 2005
    Location
    France
    Posts
    6
    Quote Originally Posted by selivem
    - just a guess
    Try to give the full path to useradd. I suppose i'ts a environment issue

    What do you mean "full patch to useradd"?

  10. #9
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    When you type "useradd", the shell goes through your $PATH and finds the first occurrence of the binary.

    So instead of doing that, use /usr/sbin/useradd.

  11. #10
    Just Joined!
    Join Date
    Nov 2005
    Location
    France
    Posts
    6
    The first tests allow me to say that you were right. I'm not able to run full tests because I have a limited access to my server (11h30PM). But I will push the tests further tomorrow to give you news


    I think that will do it. Thanks a lot

    Axel

Posting Permissions

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