Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
I have Centos 6.2, kernel 2.6.32-220.23.1.el6.x86_64 installed. I want to execute the script with user root cron .The script open browser in backend and render some value.
If I am running the script on shell it runs fine but if I run with user root crontab it doesn't run. i am using absolute path in the script but didn't work and defined path for JAVA_HOME, PATH, DISPLAY in script itself but didn't work. what need to be done to execute with crontab. Below is the script and crontab entry.
Cron doesn't have access to the display unless you are logged in. If you are not logged in, no display, and the program will error out. If someone is logged in other than root, no display, and again the program will error out.
Anything X will need the magic-cookie of the user that started X.
~/.Xauthority
And if we're talking about a chroot environmnet it'll need a lot more than that. Still not a good idea to do with cron. It's probably easier to write out a log file and tail -f /the/log/file in a terminal for anyone monitoring the "alerts".
It can depend on your system... you have to define where the .Xauthority file is located, and that can vary.
The default is ~/.Xauthority, and guided by the environment variable XAUTHORITY.
On some/many systems the file is created per login, and the file name or path changes with each login... and doesn't even need to exist (as in it gets deleted) when you logout.
Can you provide some log output? How about the cron logs, messages, X11 stuff to start with. Something concrete for us to go on. Heck, throw a -x in your shebang line and let it run so we can see the output in the cron log.
Script is opening some url in the browser using command xvfb-run and get some values. In shell it is working but with cron it doesn't
You will need to provide a log of what is being done. Using the virtual frame buffer should not be an issue as the xvfb-run creates its own authority file.
The problem you are trying to solve must be really strange - virtual frame buffer displays don't output anything.
I am attaching emails with strace results with cron and manually. Please check the strace results with cron file filename ( running with cron ) and manually with script filename ( running manually ). Please check if the information is sufficient to diagnose.
Jpollard is correct here. OP, try and write that line out by hand. do not copy and paste it. you have an invisible carriage return and newline character from mac/windows creeping in there.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.