Quote:
Originally Posted by tearsforhari
Suicidaleggroll, anyone?
I wrote the above script called "myscript.sh" and put it in a directory with path /home/scripts/myscript.sh. It works just fine. I then set several similar cronjobs, which also work just fine. But I nevertheless get an error mailed as root:
Code:
/home/scripts/myscript1.sh: 13: /home/scripts/myscript1.sh: [[: not found
/home/scripts/myscript2.sh: 23: /home/scripts/myscript2.sh: [[: not found
/home/scripts/myscript3.sh: 33: /home/scripts/myscript3.sh: [[: not found
I am wondering if this has something to do with needing to add /home/scripts to the PATH of the root user. But I don't understand why it is mailing this error when it actually worked?
|
From the error message, it looks like the shell interpreter does not understand the [[ syntax. When you run a script from cron, it may use another shell instead of bash. Put the following line first in your script, to force it to use bash:
The if..then..fi blocks are not working as expected (they are doing something, but not what you intended), but the sshfs, rsync, and umount commands appear to be working fine.