0

I have a cron and its not executing the script, from the cron logs i can see its running in the time but the script is not getting executed for some reason.

14 05 * * * /usr/local/bin/bash /home/sajeesh/bf1_scp.sh > /home/sajeesh/env.output

The above is the cron, and the script does a simple scp of a file to a different server.

    cat /home/sajeesh/bf1_scp.sh
    #!/bin/bash
    PATH=/home/y/bin64:/home/y/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/sajeesh/bin

    date=20171112

    /usr/bin/scp $hostname:/home/logs/my_newsletter/test_3.$date /home/sajeesh/directory

The scripts executes well when i run it manually and fails on cron. I am running the cron as user : sajeesh and not root. ( since root has no keyless login to other node )

Please let me know what i might be missing here.

  • 1
    Try redirecting stderr by adding `2>&1` to the end of the command. – Barmar Nov 23 '17 at 06:03
  • Is the file /home/sajeesh/env.output created? If so, try running the command `/usr/local/bin/bash /home/sajeesh/bf1_scp.sh > /home/sajeesh/env.output` from an interactive shell and see what happens. – codeforester Nov 23 '17 at 06:04
  • Where do you assign a string to $hostname? – Cyrus Nov 23 '17 at 06:25
  • https://stackoverflow.com/questions/20582224/shell-script-not-running-via-crontab-but-runs-fine-manually – Sanket Nov 23 '17 at 07:04

0 Answers0