I wanna run a script using crontab in every minute. The script is located at /Users/robin47/Desktop/script/demo.sh
. As a side note, I give the execute permission of demo.sh
file with chmod +x demo.sh
command.
But it doesn't execute the script. Here is the process I'm following:
Run crontab -e
from the terminal.
robin47@mac-pro ~ % crontab -e
this open a file(crontab.xxxxxxx) in nano which is located under tmp folder, as an example File: /tmp/crontab.V4DcXEJU8g
.
This is my crontab.xxxxxxx
file:
SHELL=/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin
* * * * * /bin/bash /Users/robin47/Desktop/script/demo.sh
Get from here, this doesn't execute my demo.sh
script.
If I run sh command from terminal like sh demo.sh
, it works. And if I directly echo(or run any command like touch, mkdir) in crontab like this
SHELL=/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin
* * * * * echo 'hello' >> /Users/robin47/Desktop/script/text.txt
It also works. But doesn't run the script using crontab. I appreciate your help, Thanks.
This is my demo.sh
file:
#!/bin/sh
echo "hello world" >> /Users/robin47/Desktop/script/text.txt