On Nov 25, 2007 8:27 PM, <[EMAIL PROTECTED]> wrote: > Scripts that test for X running might work in a shell but not when the > script is run by cron. > > For example: This code: > tty|grep pts > retval=$? > if [[ $retval > 0 ]];then > print "X isn't running just now... postponing rsync of WWW > until such time as it is... exiting" > exit > fi > > Runs fine when run from a user shell, but when cron runs it the test > always fails to be true. > > So how can I test for X running in case where script will be run by cron?
How about something like this: retval=`ps aux | grep tty | grep X | awk '{print $2}'` Or retval=`cat /tmp/.X0-lock` Or even better: if [[ -e "/tmp/.X0-lock" ]];then ... > > > -- > [EMAIL PROTECTED] mailing list > >