0

I'm running test.sh

#!/bin/bash
date >> /home/admin/scripts/cron.log.txt ; echo "app01 hat erfolgreich den cronjob in test.sh ausgefuehrt" >> /home/admin/scripts/cron.log.txt

on 2 diferent servers with a crontab -e entry on both:

# Alle 10 Min., laut cron.log erfolgreich!
*/10 * * * * sudo sh /home/admin/scripts/test.sh

That's to say, they are identical. One one server I'm getting everything in cron.log.txt, on another server it's creating cron.log.txt with date entry, and cron.log.txt? with the echo entry.

What am I doing wrong?

2
  • It's probably caused by the sudo. You can't use sudo in a crontab (or indeed in any script) because, where would it get the password from? Instead, if you need to run the shell with sudo privileges, you put it in the root crontab: sudo crontab -e.
    – Jos
    Nov 17 '20 at 11:12
  • Nah, it was because I was too stupid to transfer test.sh with WinSCP as text , instead I did as binary file. Nov 17 '20 at 12:25
0

Check if you transfered the file test.sh with WinSCP as text and not binary file.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.