Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The app is the java phone emulator and its being run from a *.sh file to run through some automated tests overnight. System is RH FC2 Final.
If I ssh into the server and run the batch I get lots of errors from java relating to not being able to create display contexts. Fair enough, I'm only on a terminal so I'd be suprised if it did work. When I'm actually at the server on KDE if I bring up a terminal, run the same command up pops the GUI window and the app runs fine. However, when the cron fired the same batch overnight I saw in the log the same errors I got when ssh'ing in, IOW it too had no access to X (?). This puzzled me because it was being run locally and X is running permanently.
Has anyone seen this before and got any ideas please? Thanks...
"If I ssh into the server and run the batch I get lots of errors from java relating to not being able to create display contexts. Fair enough, I'm only on a terminal so I'd be suprised if it did work. When I'm actually at the server on KDE if I bring up a terminal, run the same command up pops the GUI window and the app runs fine. However, when the cron fired the same batch overnight I saw in the log the same errors I got when ssh'ing in, IOW it too had no access to X (?). This puzzled me because it was being run locally and X is running permanently."
You can think of the cron job as a user when looking at this problem. Each user starts X Window or uses a terminal or whatever independently of what the other users happen to be doing. The cron job is running from a bash shell regardless of whether other users happen to be using X Window. Since the cron application is not running under X Window it fails in the same way as if a user tried to run the application without first starting X Window.
hi jailbait
itīs possible to start a script (needs xserver) with cron?
in my case i need to start a browser and run a php script, for that i have a little script that starts the browser and the php script.
if i run it from the console and manually it works fine, but cron wont do that and gets this error `cant connect to x server`.
but x server is started and im logged in as the user that starts the cron jobs.
and this user is also allowed to use the xserver(xhost + user)
maybe you know a solution....
thanx in advance
A simple way to make this work, when on a local machine which already has a local user configured and able to access the X Server, is to do something like this with the Cron job line in /etc/crontab:
I.e. the execution environment of a Cron job is rather bare as compared to your usual interactive or login environment, and it lacks those two envars, DISPLAY and XAUTHORITY.
I won't go into many of the particulars or nuances here, because there are quite a lot of them. A few installations have variable paths to their Xauthority data, for one thing. Another thing is that remote users, e.g. via ssh sessions, can't rely on the usual value for DISPLAY.
You might need to write some procedures into your script rather than simply rely on envar definitions added to the commandline of a Cron job.
A lot of that information is available elsewhere on the internet, but suffice it to say that I hope at least a few runaday users, and maybe a few novice power users, might be helped by me mentioning this tidbit here. Cheers.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.