Home » Questions » Computers [ Ask a new question ]

How to execute shell script via crontab?

How to execute shell script via crontab?

I have a notify.sh script that looks like:

Asked by: Guest | Views: 173
Total answers/comments: 3
bert [Entry]

"4 hypothesis:

the cron daemon is not running (do a ps axfww | grep cron and check)
the notify-send is trying to send output to a terminal, or an X session -- but it is ran from within the cron environment and it does not know ""who to talk to"", so to speak.
your script is not executable
the home/ path in the crontab script is relative to the user the scripts gets executed as. Try using the full path"
bert [Entry]

"First of All, we need to edit the crontab with Command crontab -eand than Inside this Crontab add the Path of Executable script and in your Case like this
* 14 * * * home/hacks/notify.sh >/dev/null 2>&1 .

Start /Stop / restart cron service

/etc/init.d/crond start /stop / restart
service crond start /stop /restart
systemctl stop crond.service

systemctl stop crond.service"
"First of All, we need to edit the crontab with Command crontab -eand than Inside this Crontab add the Path of Executable script and in your Case like this
* 14 * * * home/hacks/notify.sh >/dev/null 2>&1 .

Start /Stop / restart cron service

/etc/init.d/crond start /stop / restart
service crond start /stop /restart
systemctl stop crond.service

systemctl stop crond.service"
bert [Entry]

"quite simple, add following line at bottom of the crontab file via:
sudo nano /etc/crontab

@reboot root cd /home/pi/node-sonos-http-api && npm start &"