Hi,
I'm currently installing a CentOS 5 desktop as a public internet access point. The machine shuts down every day automatically at 22:30. Is there a way I can display a message in GNOME at 22:15 warning the user that the machine will shutdown in 15 minutes ?
Any suggestions ?
Niki Kovacs
On Tue, 2010-02-02 at 21:47 +0100, Niki Kovacs wrote:
Is there a way I can display a message in GNOME at 22:15 warning the user that the machine will shutdown in 15 minutes ?
kalarm
On Tue, 2010-02-02 at 14:57 -0600, Frank Cox wrote:
On Tue, 2010-02-02 at 21:47 +0100, Niki Kovacs wrote:
Is there a way I can display a message in GNOME at 22:15 warning the user that the machine will shutdown in 15 minutes ?
kalarm
On second thought, a bash file calling zenity in a cronjob will be better. You can have zenity show any message you want in a window on the desktop and the only option available in that window can be "ok". kalarm would allow the user to change the alarm, and that's not what you want.
Frank Cox a écrit :
On second thought, a bash file calling zenity in a cronjob will be better. You can have zenity show any message you want in a window on the desktop and the only option available in that window can be "ok". kalarm would allow the user to change the alarm, and that's not what you want.
OK, I fiddled around with this, and here's what I got so far.
1) In an open GNOME session, when I launch GNOME terminal and type this:
$ zenity --info --text "Warning message!"
... I get exactly what I want.
2) When I put this line in a bash script (/usr/local/sbin/warning.sh) and launch it from within Gnome Terminal, I get the same result (as expected).
3) But when I add it to crontab like this :
# crontab -e
15 22 * * * /usr/local/sbin/warning.sh
... nothing happens at the given time (10:15 PM).
Any idea what's wrong here?
- But when I add it to crontab like this :
# crontab -e
15 22 * * * /usr/local/sbin/warning.sh
... nothing happens at the given time (10:15 PM).
Any idea what's wrong here?
Any errors from a cron run go to your root mailbox (or whatever user's crontab it is, when applicable). Check your root mailbox for an error, I'm assuming the PATH to zenity is not set correctly. That is the usual culprit in a case like this.
--------------------------------- Geoff Galitz Blankenheim NRW, Germany http://www.galitz.org/ http://german-way.com/blog/
Geoff Galitz a écrit :
Any errors from a cron run go to your root mailbox (or whatever user's crontab it is, when applicable). Check your root mailbox for an error, I'm assuming the PATH to zenity is not set correctly. That is the usual culprit in a case like this.
No mail for root.
I googled quite some more, and I still have no clue for this. Here's what I have so far :
# crontab -l 53 16 * * * export DISPLAY=":0.0" && /usr/bin/zenity --info --text "Test"
(yes, all on one line, the wrapping only comes from my mail client)
Still not working. Which leaves me clueless.
Geoff Galitz a écrit :
Any errors from a cron run go to your root mailbox (or whatever user's crontab it is, when applicable). Check your root mailbox for an error, I'm assuming the PATH to zenity is not set correctly. That is the usual culprit in a case like this.
No mail for root.
I googled quite some more, and I still have no clue for this. Here's what I have so far :
# crontab -l 53 16 * * * export DISPLAY=":0.0" && /usr/bin/zenity --info --text "Test"
(yes, all on one line, the wrapping only comes from my mail client)
Still not working. Which leaves me clueless.
I assume you've checked /var/log/cron, to make sure it ran.
On further thought, here's a nasty one: on that line, echo $PATH. I wonder if you need all the X paths, and maybe LD_LIBRARY_PATH set, for zenity to run.
mark
m.roth@5-cent.us a écrit :
I assume you've checked /var/log/cron, to make sure it ran.
Yes, it looks so.
On further thought, here's a nasty one: on that line, echo $PATH. I wonder if you need all the X paths, and maybe LD_LIBRARY_PATH set, for zenity to run.
I think I do grasp in theory what you suggest, but I wouldn't know how to get it into practice.
Anyone got a working solution for this ?
You wrote:
m.roth@5-cent.us a écrit :
On further thought, here's a nasty one: on that line, echo $PATH. I wonder if you need all the X paths, and maybe LD_LIBRARY_PATH set, for zenity to run.
I think I do grasp in theory what you suggest, but I wouldn't know how to get it into practice.
Anyone got a working solution for this ?
Sure. To see what cron sees, just echo $PATH in that command line. If you need to put the paths in, you have a choice: put them in your shell script, before it calls zenity; the other, which I don't care for, is to put them in your crontab.
mark
m.roth@5-cent.us a écrit :
I assume you've checked /var/log/cron, to make sure it ran.
I think the problem boils down to this :
"How can I run a graphical application from crontab ?"
I gave it a shot with a simple one (/usr/bin/gcalctool) and didn't succeed either.
<rant>
Phew, how I hate having to jump through burning loops for performing such a simple task.
</rant>
Niki
I think the problem boils down to this :
"How can I run a graphical application from crontab ?"
I gave it a shot with a simple one (/usr/bin/gcalctool) and didn't succeed either.
I think if you did something like this:
----------
#!/bin/sh
# set DISPLAY export DISPLAY="localhost:0"
# send the message /usr/bin/xmessage -timeout 120 "This is my message"
# exit cleanly exit 0
---------
You'd be ok. Run that as a script, making changes for your system where appropriate and then run that script from cron. Cron makes very few assumptions about your environment, your PATHS and other environmental variables are not getting set. If you run this a script suing "#!/bin/sh" you should get a default environment as defined by your installation.
-geoff
--------------------------------- Geoff Galitz Blankenheim NRW, Germany http://www.galitz.org/ http://german-way.com/blog/
On Thu, February 4, 2010 11:26 am, Geoff Galitz wrote:
I think the problem boils down to this :
"How can I run a graphical application from crontab ?"
I gave it a shot with a simple one (/usr/bin/gcalctool) and didn't succeed either.
I think if you did something like this:
#!/bin/sh
# set DISPLAY export DISPLAY="localhost:0"
# send the message /usr/bin/xmessage -timeout 120 "This is my message"
# exit cleanly exit 0
You'd be ok. Run that as a script, making changes for your system where appropriate and then run that script from cron. Cron makes very few assumptions about your environment, your PATHS and other environmental variables are not getting set. If you run this a script suing "#!/bin/sh" you should get a default environment as defined by your installation.
The following worked fine for me on a stock 64-bit CentOS 5 box:
17 11 * * * export DISPLAY=:0 && /usr/bin/xmessage -nearmouse "test message"
However, that was executed from a non-root crontab and the same user was the owner of the X Windows session at the time. When I tried to run the same thing from root's crontab a minute later, it failed because root could not open the display. Executing "xhost +" did the trick, so you might want to take a look at display permissions.
Marko
I'm really grateful for all the responses. But could someone please just simply write down a *working* crontab line for this ?
Thanks,
Niki
On Thu, February 4, 2010 12:07 pm, Niki Kovacs wrote:
I'm really grateful for all the responses. But could someone please just simply write down a *working* crontab line for this ?
*If* the issue has to do with one user trying to display the message on a desktop owned by another user, that might not be easy. :-)
Since the crontab entry I posted earlier works for me, I would concentrate on trying to determine why exactly yours is failing. Which user owns the desktop and which user's crontab is used to run the command? The latter should receive an email from cron when something goes wrong.
Marko A. Jennings a écrit :
Since the crontab entry I posted earlier works for me, I would concentrate on trying to determine why exactly yours is failing.
Oooops. According to Murphy's law, your initial message is the only one I had been overlooking... and it's also a *working* example. Yes, it works! Thanks very much!
The solution being simply to define the cronjob for the user... since there's only one on the machine :o)
Cheers,
Niki
On Thu, 2010-02-04 at 18:45 +0100, Niki Kovacs wrote:
The solution being simply to define the cronjob for the user... since there's only one on the machine :o)
You may want to beautify it a bit and have the script check to see if the user is actually logged in before trying to bring up the message.
Hi,
I'm currently installing a CentOS 5 desktop as a public internet access point. The machine shuts down every day automatically at 22:30. Is there a way I can display a message in GNOME at 22:15 warning the user that the machine will shutdown in 15 minutes ?
Any suggestions ?
cron
mark
Hi
Not sure but I seem to remember the old write command it could to the trick.
Regards Per On Tue, 2010-02-02 at 21:47 +0100, Niki Kovacs wrote:
Hi,
I'm currently installing a CentOS 5 desktop as a public internet access point. The machine shuts down every day automatically at 22:30. Is there a way I can display a message in GNOME at 22:15 warning the user that the machine will shutdown in 15 minutes ?
Any suggestions ?
Niki Kovacs _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
On 2/2/2010 3:03 PM, Per Qvindesland wrote:
Hi
Not sure but I seem to remember the old write command it could to the trick.
write or wall will work with open terminal windows - but shutdown offers the option to send such a message itself with a grace period before the actual shutdown. It gets trickier if you want to pop up a new window on all open window managers.
xmessage is another option. I use it from time to time. It would need minimal dependencies if that is a consideration.
-geoff
--------------------------------- Geoff Galitz Blankenheim NRW, Germany http://www.galitz.org/ http://german-way.com/blog/
I'm currently installing a CentOS 5 desktop as a public internet access point. The machine shuts down every day automatically at 22:30. Is there a way I can display a message in GNOME at 22:15 warning the user that the machine will shutdown in 15 minutes ?
Any suggestions ?
cron and xmessage.
Jobst
On Tue, Feb 02, 2010 at 09:47:20PM +0100, Niki Kovacs (contact@kikinovak.net) wrote:
Hi,
I'm currently installing a CentOS 5 desktop as a public internet access point. The machine shuts down every day automatically at 22:30. Is there a way I can display a message in GNOME at 22:15 warning the user that the machine will shutdown in 15 minutes ?
Any suggestions ?
Niki Kovacs _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
At Tue, 02 Feb 2010 21:47:20 +0100 CentOS mailing list centos@centos.org wrote:
Hi,
I'm currently installing a CentOS 5 desktop as a public internet access point. The machine shuts down every day automatically at 22:30. Is there a way I can display a message in GNOME at 22:15 warning the user that the machine will shutdown in 15 minutes ?
I believe the shutdown command automagically generates warning. I would *guess* that GNOME would have some applet that monitors these sorts of warnings and creates popups.
Any suggestions ?
Niki Kovacs _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
On Tue, 2010-02-02 at 18:30 -0500, Robert Heller wrote:
I believe the shutdown command automagically generates warning. I would *guess* that GNOME would have some applet that monitors these sorts of warnings and creates popups.
I haven't seen one, unless the user happens to have a gnome-terminal window open, in which case a warning appears in that terminal. Otherwise, not.
That's only on terminals (tty's, xterm, console) OR if you have xconsole open.
jobst
On Tue, Feb 02, 2010 at 06:30:15PM -0500, Robert Heller (heller@deepsoft.com) wrote:
At Tue, 02 Feb 2010 21:47:20 +0100 CentOS mailing list centos@centos.org wrote:
Hi,
I'm currently installing a CentOS 5 desktop as a public internet access point. The machine shuts down every day automatically at 22:30. Is there a way I can display a message in GNOME at 22:15 warning the user that the machine will shutdown in 15 minutes ?
I believe the shutdown command automagically generates warning. I would *guess* that GNOME would have some applet that monitors these sorts of warnings and creates popups.
Any suggestions ?
Niki Kovacs _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
-- Robert Heller -- 978-544-6933 Deepwoods Software -- Download the Model Railroad System http://www.deepsoft.com/ -- Binaries for Linux and MS-Windows heller@deepsoft.com -- http://www.deepsoft.com/ModelRailroadSystem/
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos