Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Need help with a cron job

  • 05-12-2003 12:08pm
    #1
    Registered Users, Registered Users 2 Posts: 1,569 ✭✭✭


    I've written this script to grab the mozilla source (with the firebird and thunderbird directories checked out) and make a tarball, and it works fine if I execute it from the command line, but if I try to crontab it it fails each time...

    [PHP]
    #!/bin/ksh

    #Define Variables
    TMPDIR="/tmp/maxheadsourcescript"
    WEBDIR="$HOME/www/mozilla-source"

    #Make Temp Directory and untar old source tree
    mkdir $TMPDIR
    cp $WEBDIR/latest-trunk/firebird-thunderbird-source.tar.gz $TMPDIR
    cd $TMPDIR
    tar -xzf firebird-thunderbird-source.tar.gz
    rm -f firebird-thunderbird-source.tar.gz

    #CVS Pull
    cd $TMPDIR/mozilla
    make -f client.mk checkout

    #Get date / time and generate tarball
    CVSTIME=`date +%Y-%m-%d-%H-%M`
    echo $CVSTIME
    cd $TMPDIR
    tar -czf firebird-thunderbird-source.tar.gz mozilla

    #Make Directory in www
    cd $WEBDIR
    mkdir $CVSTIME-trunk

    #Copy in tarball
    cd $CVSTIME-trunk
    cp $TMPDIR/firebird-thunderbird-source.tar.gz .
    cp $TMPDIR/cvsco.log .
    cd ..

    #Link latest-trunk
    rm -f $WEBDIR/latest-trunk
    ln -s $CVSTIME-trunk latest-trunk

    #Clean up temp files
    rm -rf $TMPDIR

    #CHMOD file to make workd viewable
    cd $WEBDIR
    chmod --recursive 755 latest-trunk
    [/PHP]

    This is the error mail from cron:
    Your "cron" job on matrix
    $HOME/sourcescript.sh
    
    produced the following output:
    
    tar: z: unknown option
    Usage: tar {txruc}[vfbFXhiBDEelmopwnq[0-7]] [-k size] [tapefile] [blocksize] [exclude-file] [-I include-file] files ...
    /home/maxhead/sourcescript.sh[15]: /tmp/maxheadsourcescript/mozilla:  not found
    /home/maxhead/sourcescript.sh[16]: make:  not found
    2003-12-05-12-03
    tar: z: unknown option
    Usage: tar {txruc}[vfbFXhiBDEelmopwnq[0-7]] [-k size] [tapefile] [blocksize] [exclude-file] [-I include-file] files ...
    cp: cannot access /tmp/maxheadsourcescript/firebird-thunderbird-source.tar.gz
    cp: cannot access /tmp/maxheadsourcescript/cvsco.log
    chmod: WARNING: can't access 755
    chmod: ERROR: invalid mode
    

    I really can't understand what's wrong here, but I've never actually written a script and crontabbed it before so its possible that I'm missing something really obvious (tar seems to have a problem with the z option when cron runs the script?).


Comments

  • Closed Accounts Posts: 5,564 ✭✭✭Typedef


    maybe

    zcat file.tar.gz | tar x


  • Registered Users, Registered Users 2 Posts: 1,186 ✭✭✭davej


    The crontab uses the default shell to execute, which may have different paths set than your normal a/c. So cron could be running a different version of tar that doesn't support the 'z' option. Eg the default tar that comes with Solaris doesn't support it.

    Try to specifiy the full path to tar in your script....

    ("which tar" will tell you the path)


    davej


  • Registered Users, Registered Users 2 Posts: 1,569 ✭✭✭maxheadroom


    dave,

    Thanks for that - hit the nail right on the head. I used the full path to tar, then CVS started complaining so I just got lazy and redefined the PATH variable within the script...


Advertisement