I have already tried half of askubuntu but still not succeeding. I got the following shell script:
#!/bin/bash echo "test" > "/mnt/ssd/test.txt" echo "test"
And the following crontab -e line:
* * * * * /mnt/ssd/test.sh > /mnt/ssd/cron.log
When I add a line to the cron.log file manually, it will be empty each new minute what tells me the cron is being fired.
I also tried the following cronjob:
* * * * * env > /mnt/ssd/env.output
This gave me these values:
LANGUAGE=nl_NL.UTF-8 HOME=/home/pi LOGNAME=pi PATH=/usr/bin:/bin LANG=nl_NL.UTF-8 SHELL=/bin/sh LC_ALL=nl_NL.UTF-8 PWD=/home/pi
It again tells me the cron is working and the SHELL is correct right?
I tried this cron as well:
* * * * * PATH=/bin:/sbin:/usr/bin:/usr/sbin /mnt/ssd/test.sh > /mnt/ssd/cron.log
Neither this writes anything to the cron.log file or is creating the test.txt file.
I am kinda confused. If my PATH is wrong am I trying to correct this in the right manner or is something else incorrect?
EDIT: thanks to @steeldrive it was found that the drive this script was located on was mounted with noexec type. Meaning a bash file can not normally be executed. Placing 'bash' in front of the command made it work. The command now looks like:
* * * * * bash /mnt/ssd/test.sh > /mnt/ssd/cron.log 2>&1
the 2>&1 is added so errors would also be outputted to the log file.