Search code examples
linuxbashserverubuntu-18.04scp

i am using pemkey scp not wok in crontab. but run mannualy it work


On a ubuntu setup I have a script like this:

#!/bin/bash 
scp -i my.pem /home/fileupload/*txt username@ipserver:/home/loc
exit

i run mannualy it work without cron

thank you


Solution

  • Suggest to use absolute path to everything in your script.

    #!/bin/bash 
    /usr/bin/scp -i /home/<USER_NAME>/my.pem /home/fileupload/*txt username@ipserver:/home/loc
    exit
    

    Make sure the crontab is assigned to user <USER_NAME>

    In crontab line use absolute path as well.