So in the past I just did a simple shutdown crontab, and that was it. Lately, I want to do something a bit more complex, so I'm trying to get it to run a script. Right now I've boiled it down to a super test script, called test.sh. This script just echoes something to the console and to a file.
However, no matter how many times I try, it doesn't seem to be working. Here is the script:
#!/bin/bash
echo "Console foo!!!"
echo "Foo!!!" > ~/foo22.txt
And here is my crontab:
08 18 * * * /home/craig/Documents/Scripts/test.sh
I've double and triple checked the path to the file, it's good. The script is executable, I can run it manually from the terminal and it executes.
I'm doing this in the root crontab, ie "sudo crontab -e", if that helps at all.
ls -l /home/craig/Documents/Scripts/test.shandgrep -i cron /var/log/syslog/.rootwould allow that user (or anyone who compromises that account) to gain root by altering what the script does. Other problems might include NFS or home directory encryption which may preventrootfrom accessing that directory.HOMEis one of the few that are defined. Using~or"$HOME"is fine.