LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-02-2012, 09:22 AM   #1
jao_madn
Member
 
Registered: Jun 2010
Posts: 47

Rep: Reputation: 0
how to accomplished to run zenity in cronjob


Hi,

I would like to ask some few questions about zenity. I write a script that would generate a report if any changes on the files. i want to used zenity to had a visual alarm report if theres some changes on the comparisons of the file.I used this line of zenity but it doesn't work in cronjob. I terminal windows it works fine(the scripts and the zenity line)

Code:
cat /home/user/tmp/change_report_file | /usr/bin/zenity --text-info --title="Package Change Report" --width=800 --height=300 > /dev/null 2>&1 &
 
Old 04-02-2012, 11:10 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,577
Blog Entries: 31

Rep: Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196
Assuming this is on a personal computer with a single user logged on to a graphical desktop and the user's logon shell is bash ...

The user needs to allow access to their X session from the local system. A ~/.bash_profile containing this would do it:
Code:
[[ $DISPLAY ]] && /usr/bin/xhost +localhost
The script run from cron needs to set DISPLAY before running zenity:
Code:
export DISPLAY='localhost:0.0'

Last edited by catkin; 04-02-2012 at 11:11 AM. Reason: xenity -> zenity
 
Old 04-02-2012, 02:37 PM   #3
jao_madn
Member
 
Registered: Jun 2010
Posts: 47

Original Poster
Rep: Reputation: 0
@catkin: thanks for speedy reply

I was about to try your suggestion but some how i found this link "Running X app from crontab"

what i used was the --diplay=:0.0 option in the zenity which is

Code:
cat /home/user/tmp/zenity | /usr/bin/zenity --text-info --title="Package Change Report" --width=800 --height=300 --display=:0.0
Thanks and Best Regards
 
Old 04-02-2012, 10:30 PM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,577
Blog Entries: 31

Rep: Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196
Glad you solved it

The advice in the linked page to use ~/.bashrc for the xhost command is not robust. It will only work if one of the Bash Startup Files for an interactive logon shell sources ~/.bashrc. It is common practice to do so but not universal.

If xhost is run unconditionally, it will result in an error when the user logs on at a virtual terminal: xhost: unable to open display "". Making it conditional on $DISPLAY being set as I posted avoids this.

Threads can be marked SOLVED via the Thread Tools menu.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cronjob did not run casperdaghost Linux - Newbie 15 12-22-2011 10:48 AM
[SOLVED] Cronjob to run every other weekday linuxguy7820 Linux - Newbie 2 10-27-2011 01:38 PM
run cronjob once every three months noir911 Linux - Server 2 04-30-2010 03:30 PM
cronjob to run every 15 minutes? your_shadow03 Linux - Newbie 5 11-19-2009 10:58 PM
why do these cronjob not run? SheldonPlankton Linux - General 1 01-05-2005 08:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration