Thread: Cron Problem

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

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    262
    Rep Power
    14

    Cron Problem


    Hello,

    I am running a cron job to call a shell script which simply copies a file from another server. I have installed keychain and ssh agent to authorise the server. When I run the shell script from the command line it works fine.

    The script is as follows:

    #! /bin/sh

    #Copy everything from the sites directory on the server
    scp user@server.domain.co.uk:/root/to/file /root/to/save

    exit

    And the entry in my crontab (I've tried as root and my own user) for testing:

    38 * * * * /path/to/script

    When I look at the process list on minute 38, the cron job appears and the scp command is processed. However I never end up with the file.

    Anybody any ideas why?

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    191
    maybe its a search path problem:

    try /usr/sbin/ssh ...

    users usually have different search path setup than cron has...

    [edit]
    /usr/sbin/scp of course
    [/edit]
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    entlegen
    Posts
    442
    Rep Power
    13

    that is no right for scp


    #! /bin/sh
    date1=`date`
    title=$date1

    #Copy everything from the sites directory on the server
    scp password=password -r -v -4 -P 22 sally@192.168.1.80:/var/qmail /var/save
    #server.domain.co.uk:/root/to/file /root/to/save
    date2=`date`
    title2=$date2
    echo "scp completed" | mail -s "completed backup start at $title ended at $title2"
    exit

    [root@energy sally]# ./scp-test
    Executing: exec cp -r password=password /var/save
    cp: cannot stat `password=password': No such file or directory
    Executing: program /usr/bin/ssh host 192.168.1.80, user sally, command scp -v -r -d -f /var/qmail
    /var/save: No such file or directory
    You must specify direct recipients with -s, -c, or -b.
    [root@energy sally]# sally@192.168.1.80's password:
    Permission denied, please try again.
    sally@192.168.1.80's password:
    Permission denied, please try again.
    sally@192.168.1.80's password:
    Permission denied (publickey,password,keyboard-interactive).


    not working at all. any ideas are welcome
    regards,

    wish to use AT 89c51 single chip computer to do remote sensing and send the data back from woods to office via nokie 3330 and internet. HOW?
    first I must revise C program thro' example, what's next?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    Kamloops, BC, Canada
    Posts
    55
    Rep Power
    13

    Cool


    What you want to do is create a new key pair, without a passphrase. Copy the public portion of this keypair to the ~/.ssh/authorized_keys file of the user you will be signing in as. Copy the rivate portion of this keypair to ~/.ssh/ on the client machine.

    Then, modify your script to read as follows:
    Code:
    #! /bin/sh
    email="admin@company.com"
    date1=`date`
    
    #Copy everything from the sites directory on the server
    scp -r -i /path/to/private/key/file sally@192.168.1.80:/var/qmail /var/save
    date2=`date`
    echo -e "backup start: ${date1}\nbackup ended: ${date2}" | mail -s "SCP complete" ${email}
    exit 0
    Voila. Test it a few times from the command-line before adding it to cron.
    Linux is for those who hate Windows.
    FreeBSD is for those who love UNIX.
    -------
    Have you read The Handbook yet?
    How about The FAQ?
    Have you searched the mailing lists?
    Or read any of the man pages?
    Have you searched the web for BSD resources?
    In short, have you done your homework yet?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    entlegen
    Posts
    442
    Rep Power
    13
    I have left this untouch, sorry about this.

    I tried to-morrow and more communication will be needed.

    TIA.
    regards,

    wish to use AT 89c51 single chip computer to do remote sensing and send the data back from woods to office via nokie 3330 and internet. HOW?
    first I must revise C program thro' example, what's next?
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    entlegen
    Posts
    442
    Rep Power
    13
    I have installed the gnupgp.org , it has too many parmeter to generate the publc key.



    scp -r -i /path/to/private/key/file sally@192.168.1.80:/var/qmail /var/save

    can u help with this?
    Last edited by pentium5; May 24th, 2002 at 10:54 AM.
    regards,

    wish to use AT 89c51 single chip computer to do remote sensing and send the data back from woods to office via nokie 3330 and internet. HOW?
    first I must revise C program thro' example, what's next?

IMN logo majestic logo threadwatch logo seochat tools logo