notify.sh script file looks like:

notify-send "hi welcome"

my crontab notification for 2 pm:

* 14 * * * home/hacks/notify.sh

This is very basic queston only.But it wont working. should i configure anything?

link|improve this question
Are you sure you want this script run every minute during the 2pm hour? If not, then you'll want to set the crontab entry to be 0 14 * * * – Darren Hall Dec 10 '09 at 9:56
1  
Now .. Accept the answer which you think helped .. – infant programmer 'Aravind' Dec 16 '09 at 11:45
@infant: probably the OP was abducted by aliens as many hereabout... – dag729 Jul 30 '10 at 0:32
feedback

5 Answers

Your script is missing a #! line at the start, which is the magic interpreted by the kernel to say which command interpreter is to be used for the script.

Make it look like this:

#!/bin/sh
notify-send "hi welcome"

and make sure the script is executable:

ls -l home/hacks/notify.sh
chmod +x home/hacks/notify.sh
ls -l home/hacks/notify.sh

Also, since you're asking for this to happen just once a day, is the timezone of the crontab the same as your own timezone? You might find this happening at 2pm GMT.

link|improve this answer
+1 for good info – mrduclaw Dec 10 '09 at 10:22
feedback

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

link|improve this answer
feedback

Making crontab running is easy only . here i am going to say how to run crontab jobs. It is useful for anyone who is stuck on crontab.

*/1 * * * * cd /home/hacks && sh notify.sh

To change executable

chmod +x home/hacks/notify.sh

Here i run this script for every one minute ... By doing below script, u can write it in a log file to find whether its working

write log

*/1 * * * * cd /home/hacks && sh notify.sh>>test.log

send mail

*/1 * * * * cd /home/hacks && sh notify.sh>>test.log | mail -s "Hi this is example" user@domain.com
link|improve this answer
feedback

You have to open crontab by the following command:

crontab -u username -e (to edit) -l(to list) -r(to remove) 10(minutes) 8-15(hours) *(Day of month) *(month) 1,3,5(days of week) /path/to/script/script_name.sh

This will run your script once an hour from 8AM-3PM at 10 minutes past the hour every Monday, Wednesday and Friday.

link|improve this answer
feedback

Add export DISPLAY=:0 above the notify-send line in your script. This addresses lornezog's second point.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.