LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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



Reply
 
Search this Thread
Old 05-23-2012, 04:01 AM   #1
Beaverfriend
LQ Newbie
 
Registered: Feb 2010
Posts: 7

Rep: Reputation: 0
Run cron job in terminal emulator window


Hi,

I have a backup script that I would like to open up a new terminal emulator window every day it runs from cron, so I can follow what's happening.

How can this be achieved?

Looking forward to your answer! Thanks!
 
Old 05-23-2012, 04:10 AM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 208Reputation: 208Reputation: 208
The better solution is to have your cron job write to a log file.

Then, you can run
Code:
tail -f /log/file
But, what you propose is likely possible. You'd need to "wrap" your existing script with code like this, below. This gets a handle to the GUI session, and then launches gnome-terminal, running your command.

Code:
#!/bin/bash
# This is your new cron script.
# 

user="your-username-here"

dbus_address=$(cat /home/$user/.dbus/session-bus/*-0 | \
                grep -v '\#' | \
                grep BUS_ADDRESS | \
                cut -d '=' -f 2-)

# Here, replace /path/to/script.sh with whatever the old cron script was.
DBUS_SESSION_BUS_ADDRESS=$dbus_address \
    su $user -c gnome-terminal -e "sudo /path/to/script.sh"
Anyway, there are still a lot of issues with this. Please don't try to do it; you'd be better off looking at Nagios or some other monitoring software.

Last edited by jhwilliams; 05-23-2012 at 04:13 AM.
 
Old 05-23-2012, 05:23 AM   #3
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
Hi Beaverfriend

Maybe you could try running your script in screen
like:
- this
- or maybe here

good luck
 
Old 05-24-2012, 05:06 AM   #4
Beaverfriend
LQ Newbie
 
Registered: Feb 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jhwilliams View Post
The better solution is to have your cron job write to a log file.
You're right, that would be the better solution! Thanks all for tips everyone!
 
  


Reply

Tags
backup, bash, cron, script, terminal


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
Debian daily cron job won't run, but does run in cron.hourly. sandersch Linux - General 7 05-24-2012 02:50 AM
Focusing the terminal emulator window in Kate Shay Linux - Software 1 11-01-2006 03:15 PM
how to run this cron job ashley75 Linux - General 5 05-24-2004 12:20 PM
Cron job does not run brentos Linux - General 6 12-12-2003 03:37 PM
What terminal emulator will run from.... Rikarus Linux - Software 9 05-12-2003 03:58 PM


All times are GMT -5. The time now is 06:56 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration