LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-22-2010, 04:40 AM   #1
Markus2010
LQ Newbie
 
Registered: Dec 2010
Posts: 1

Rep: Reputation: 0
Pop up message from cronjob run script


Hi,

I'm working on a bash script that will be run regularly via a cronjob. As there is no easy way for the user
to see if it's running in the background, I'd like a have some kind of pop up window what say's something
like "Process started" and "Process finished" when it's complete.

I’ve read though some similar threads and came across xmessage. It kind of does what I want, with the
exception of:-
  • I’d like the message “Process started” to stay up for the whole process, but it looks like the script
    won’t continue until the xmessage window is closed.
  • I can’t get any xmessages to appear when the script is run from a cronjob. It only appears if I run the script manually from a terminal window. Which is no good for me.

If anyone has any suggestions that would be great and just to add, it's doesn't have to be xmessage, any text box would do.

I'm working with Redhat 4 and 5, if that makes a difference.

Thanks,

Markus

Chuck Norris destroyed the periodic table, because he only recognises the element of surprise.
 
Old 12-22-2010, 05:05 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
There are several alternatives to xmessage including zenity and yad. yad is the most fully featured and is actively being developed.

X applications need to know the name of the X display to open in. Most commonly they get it from the $DISPLAY environment variable. That is set for all processes run within an X session but not when run from cron. If there is only one X display running on the system, you can use export DISPLAY='localhost:0.0' in the script (you may also need export LANG=C, I can't remember why ). If the cron job is not being run by the same user as the X display belongs to, the user needs to give the cron user permission to access their X display using the xauth command.

Regards the script continuing while the message remains on screen, it should (TM) be possible to "background" the message command using &, note its process ID from the value of $! and then kill it when the script has finished and displays the "Process finished" message.

If using yad, you may find the --on-top and --sticky options useful. IDK if they are available in the alternatives.
 
Old 12-22-2010, 06:55 AM   #3
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,631

Rep: Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696
script run from cron

Generally cron is used for running scheduled events. It should not require someone be logged into the machine, much less have a 'gui' style desktop running upon which it might open a message window.

Think about this: if 5 people were logged in running 7 desktop sessions, how would your script decide where to display its window?

Not that it cannot be done, but it is a bit like driving screws in with a hammer: you are misusing your tools!
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cronjob to run every 15 minutes? your_shadow03 Linux - Newbie 5 11-19-2009 10:58 PM
run a shell script/cronjob when any email arrive to specific email address ikillu Linux - General 3 05-30-2009 08:18 AM
why do these cronjob not run? SheldonPlankton Linux - General 1 01-05-2005 08:01 PM
Permision Denied message when trying to run a Perl Script kurtb1234 Linux - Newbie 4 12-10-2004 12:53 PM
how to produce pop-up message box / alert window from shell script peb Linux - Newbie 3 02-25-2004 03:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:17 PM.

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