LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-23-2010, 03:11 PM   #1
fdelval
Member
 
Registered: Feb 2010
Posts: 107

Rep: Reputation: 15
crontab + libnotify


Hello all:

i did a script called MYSCRIPT like this:

Code:

Code:
echo "hello"
/usr/bin/notify-send "hello"
echo hello > /root/msg.txt
saved it in /root directory, applied chmod +x

So, if i type in a shell: ./MYSCRIPT, it nicely show me HELLO in the shell, and HELLO in a graphical popup

ok, now i create another script MYSCRIPTcron



Code:
*/1 * * * * /root/MYSCRIPT
saved it in /root directory, applied chmod +x

now, i added it: crontab -r; crontab MYSCRIPTcron; crontab -l
and i see it in the crontab list.

Everytime i check /root, i can see the file called msg.txt, if i delete it, it appears each minute, so crontab is working

BUT I CANT GET IT TO SHOW ME ANY NOTIFICACION

i also tryed with



Code:
*/1 * * * * DISPLAY=:0.0 /root/MYSCRIPT
what must i do to get a popup, or a shell message with that "hello" message?
 
Old 02-23-2010, 04:53 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

notify-send uses dbus. Read this for a solution:
http://earlruby.org/2008/08/update-p...us-using-cron/

Dave
 
Old 02-23-2010, 05:06 PM   #3
fdelval
Member
 
Registered: Feb 2010
Posts: 107

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by ilikejam View Post
Hi.

notify-send uses dbus. Read this for a solution:
http://earlruby.org/2008/08/update-p...us-using-cron/

Dave
i will sure check that link Dave

any idea for a non graphical output, i mean, getting the advices in a shell or.. i dont know..

my first try was setting cron in the foreground, but i think thats no possible.. am i right?
 
Old 02-23-2010, 05:17 PM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

It would probably be easier to use an xmessage or maybe a zenity alert if you want a graphic alert - you'll still have to set the DISPLAY variable, though.

You could also use 'write' to send a message to a user's shell(s). I've just found out that the KDE notifier also pops up a message when it hears a 'write' message. Gnome may do a similar thing. By default (on Fedora at least) 'write' permission is switched off. Run 'mesg y' in a shell to turn it on.

Dave
 
Old 02-23-2010, 06:47 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Some good advice there. If you're building up to msging all users, you want 'wall' http://linux.die.net/man/1/wall instead of write.
http://linux.die.net/man/1/mesg
http://linux.die.net/man/1/write
 
Old 02-24-2010, 02:11 AM   #6
fdelval
Member
 
Registered: Feb 2010
Posts: 107

Original Poster
Rep: Reputation: 15
Interesting, i will comment later today when i try it.


Just to finish to understand cron, it always performs the task in the background right? no way to make it in the foreground?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Libnotify and notify-send problems J_Humphrey Slackware 8 07-27-2010 04:43 PM
Slackware and libnotify problem neosix Slackware 9 02-11-2010 08:07 AM
LIBNOTIFY, no where to be found tqwillis Linux - Newbie 4 03-19-2009 10:13 AM
replaced crontab, now should get crontab back to what it was raminn Linux - Newbie 2 10-20-2008 07:15 PM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration