#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    4
    Rep Power
    0

    Problem perl script working manually, but not with cron


    Hi,

    I just did a script in the purpose to save all directory from a specific one's (/var/www/html ).
    The script works perfectly when launched manually, but not at all when it's the cron that launch it automatically =/

    here's the script =>

    Code:
    for SITE in `ls $MYDIR | grep -v "chroot\|default"` ; do
            if [ -d $MYDIR${SITE} ]; then
                    echo 'here, before tar '$MYDIR${SITE} >> log.txt
                    tar -czvf ./${SITE}.tar.gz $MYDIR${SITE}
            fi
    done
    I just have no idea what's going on, i checked into the log.txt, the path and the directory name are good, but, it looks like only one directory has been zipped.

    Here's what i got from the log =>
    here, before tar /var/www/html/le_nom_du_site
    Hoping someone could give me a hint on this issue,

    Hurin

    PS: sorry for my low english level ^^
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2007
    Posts
    765
    Rep Power
    929
    FYI, that is a shell script, not a perl script and the actual issue is linux/unix related. This kind of question would be better raised in the Linux, Unix or Other Languages forum.

    The problem is the environment is different between when you run the shell script & cron does. In this case, most likely the problem is the "./${SITE}.tar.gz" in the tar command assumes a certain working directory. You can either qualify this with an absolute path, or use the "cd" command at the start of the script.
    sub{*{$::{$_}}{CODE}==$_[0]&& print for(%:: )}->(\&Meh);
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    4
    Rep Power
    0
    Originally Posted by OmegaZero
    FYI, that is a shell script, not a perl script and the actual issue is linux/unix related. This kind of question would be better raised in the Linux, Unix or Other Languages forum.

    The problem is the environment is different between when you run the shell script & cron does. In this case, most likely the problem is the "./${SITE}.tar.gz" in the tar command assumes a certain working directory. You can either qualify this with an absolute path, or use the "cd" command at the start of the script.
    Ok, thanks OmegaZero, i will create another thread in a better place, sorry for the error -_-"

IMN logo majestic logo threadwatch logo seochat tools logo