Gentoo Archives: gentoo-user

From: Andrey Falko <ma3oxuct@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] How to tell Cron X is running or not
Date: Mon, 26 Nov 2007 02:03:38
Message-Id: 350fc7cf0711251756y66793347p70be0ddb9324cfe5@mail.gmail.com
In Reply to: [gentoo-user] How to tell Cron X is running or not by reader@newsguy.com
1 On Nov 25, 2007 8:27 PM, <reader@×××××××.com> wrote:
2
3 > Scripts that test for X running might work in a shell but not when the
4 > script is run by cron.
5 >
6 > For example: This code:
7 > tty|grep pts
8 > retval=$?
9 > if [[ $retval > 0 ]];then
10 > print "X isn't running just now... postponing rsync of WWW
11 > until such time as it is... exiting"
12 > exit
13 > fi
14 >
15 > Runs fine when run from a user shell, but when cron runs it the test
16 > always fails to be true.
17 >
18 > So how can I test for X running in case where script will be run by cron?
19
20
21 How about something like this: retval=`ps aux | grep tty | grep X | awk
22 '{print $2}'`
23
24 Or retval=`cat /tmp/.X0-lock`
25
26 Or even better:
27
28 if [[ -e "/tmp/.X0-lock" ]];then
29 ...
30
31
32
33 >
34 >
35 > --
36 > gentoo-user@g.o mailing list
37 >
38 >

Replies

Subject Author
[gentoo-user] Re: How to tell Cron X is running or not reader@×××××××.com