- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to set DISPLAY variable thru cron when no ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2005 09:33 PM
тАО11-23-2005 09:33 PM
How to set DISPLAY variable thru cron when no tty
the WebSphere server.
To run the client components (java) from the server we need to export the DISPLAY variable
on the command line. This works fine.
I have taken it a step further and automated my startup that the DISPLAY is dynamically set so that after our login via telnet
or reflexionX telnet we do not need to
do export DISPLAY=blabla:0.0, because
it is already set. This works great!!
How do I do that?
Like this:
--------------------------------
tty
TTY=$(eval tty | awk -F "/dev/" {' print $2'})
DISPLAY=$(who -u | grep $TTY | awk {' print $8 '}):0.0
export DISPLAY
----------------------------------
This works fine !!
But now I used this same script in the cron to
stop the WebSphere server on weekends
and start it again and I get a message
in the log:
+ tty
not a tty
+ awk -F /dev/ { print $2}
+ eval tty
+ tty
+ export TTY=
+ + who -u
+ awk { print $8 }
+ grep
usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] -e pattern_list...
[-f pattern_file...] [file...]
usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] [-e pattern_list...]
-f pattern_file... [file...]
usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] pattern [file...]
DISPLAY=:0.0
So yeah that makes sense, cron that not
use tty. Still I would like the DISPLAY
to be set, how to do that ?
Is there a workaround to set the DISPLAY
at all in cron or is it a no go ?
Tx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2005 09:54 PM
тАО11-23-2005 09:54 PM
Re: How to set DISPLAY variable thru cron when no tty
Try to put this in a script and execute with sudo utility.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2005 09:59 PM
тАО11-23-2005 09:59 PM
Re: How to set DISPLAY variable thru cron when no tty
cron tab is saying that not a tty. You have to execute tty command by that user only.
Refer this:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=973600
Use sudo utility to execute a command by that user itself.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2005 10:00 PM
тАО11-23-2005 10:00 PM
Re: How to set DISPLAY variable thru cron when no tty
I am not entirely with you.
Yes we use sudo !!
But I fail to see the relationship between
running cron and using sudo.
I am curious as to what you mean.
Thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2005 10:06 PM
тАО11-23-2005 10:06 PM
Re: How to set DISPLAY variable thru cron when no tty
tty informations can be only taken by root and normal users (those who can login with terminal).
Create a script like,
#!/bin/ksh
#display.ksh
PATH=$PATH:/usr/bin
tty
TTY=$(eval tty | awk -F "/dev/" {' print $2'})
DISPLAY=$(who -u | grep $TTY | awk {' print $8 '}):0.0
export DISPLAY
exit 0
#
cron tab entry
===========
x x x x x
Now it will work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2005 10:10 PM
тАО11-23-2005 10:10 PM
Re: How to set DISPLAY variable thru cron when no tty
You assumed I need root privileges ?
I had not listed my cronjob:
35 9 * * 4 su - root -c "/etc/cmcluster/devnew/WebSphere_Start.sh > /tmp/WebSphere_Start_devnew.cronlog 2>&1"
The scripts is run as a root user,
and with with that user there is not
tty attached when scheduled by cron.
Hence my DISPLAY is not set properly.
I am looking for a workaround for that.
For clarity: I am not looking for a way
to promote my user with SUDO or otherwise
to attain certain privileges.
Hope others have a better idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2005 10:18 PM
тАО11-23-2005 10:18 PM
Re: How to set DISPLAY variable thru cron when no tty
DISPLAY="$(who -mu | awk '{ print $8 }'|xargs getip):0.0"
It will not need any TTY settings.
not a tty standard input is not a terminal or pseudo-terminal for tty.
May be execution with cron is pseudo-terminal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2005 10:31 PM
тАО11-23-2005 10:31 PM
Re: How to set DISPLAY variable thru cron when no tty
looks like a winner,
I will try it after lunch.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-24-2005 12:49 AM
тАО11-24-2005 12:49 AM
Re: How to set DISPLAY variable thru cron when no tty
Do you try the stuff that you advice ?
Because it appears your axioma that
tty is not used is incorrect.
I received error on your line:
DISPLAY="$(who -mu |awk '{ print $8 }'|xargs getip):0.0"
-------------------------------------------
+ + who -mu
+ awk { print $8 }
+ xargs getip
process not attached to terminal
Usage: who [-rbtpludAasHTqRm] [am i] [utmp_like_file]
r run level
b boot time
t time changes
p processes other than getty or users
l login processes
u useful information
d dead processes
A accounting information
a all (rbtpludA options)
s short form of who (no time since last output or pid)
H print header
T status of tty (+ writable, - not writable, x exclusive open, ? hung)
q quick who
R print host name
Usage: getip host
DISPLAY=:0.0
+ export DISPLAY
------------------------------
Sorry I can't give any points for that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-24-2005 02:20 AM
тАО11-24-2005 02:20 AM
Re: How to set DISPLAY variable thru cron when no tty
You cannot set a fancy DISPLAY like that for cron usage... since you shell is not interactive.
If you wish to do so, you will have to setup a virtual frame buffer server or appropiate software (xvnc):
Look at this link:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=758230
All the best
Victor