LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-08-2006, 02:27 PM   #1
rollo
Member
 
Registered: Apr 2004
Location: France
Distribution: Debian Sid (Kanotix)
Posts: 237

Rep: Reputation: 30
Cron won't open console to run script


I am trying to get cron to run a script in a console. The script must run in a console because it requires interaction. Using KCron, I have added the line:

Code:
/usr/bin/konsole -e /home/rollo/scripts/script.sh
to crontab (which one..?), which makes crontab -l produce this:

Code:
rollo@KanotixBox:/var/mail$ crontab -l
#
0 21 * * *      /usr/bin/konsole -e /home/rollo/scripts.script.sh
# This file was written by KCron. Copyright (c) 1999, Gary Meyer
# Although KCron supports most crontab formats, use care when editing.
# Note: Lines beginning with "#\" indicates a disabled task.
The script seems to run at the correct time (judging by the output of ps), but Konsole doesn't open. Which is no use because it's interactive.

Run directly from KCron ("Run it now"), the script works fine and Konsole opens correctly.

What could be going on? Help much appreciated.
 
Old 11-08-2006, 04:03 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Probably needs your $DISPLAY variable exported.
 
Old 11-09-2006, 12:49 PM   #3
rollo
Member
 
Registered: Apr 2004
Location: France
Distribution: Debian Sid (Kanotix)
Posts: 237

Original Poster
Rep: Reputation: 30
Unhappy

Thanks for that.

My cron command now reads:

Code:
40 19 * * *   DISPLAY=0.0; export DISPLAY; /usr/bin/konsole -e /home/rollo/scripts/script.sh
But still Konsole doesn't run.

What am I doing wrong here?..
 
Old 11-10-2006, 07:11 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Add the line export DISPLAY=":0.0" inside your script.sh below the bang (!#/bin/someshell) line.
 
Old 11-10-2006, 12:50 PM   #5
rollo
Member
 
Registered: Apr 2004
Location: France
Distribution: Debian Sid (Kanotix)
Posts: 237

Original Poster
Rep: Reputation: 30
Thanks again.

Adding the export variable line in the script makes no difference. Presumably because by that stage cron has already failed to run /usr/bin/konsole. Reminder of the cron line:

Code:
0 21 * * *      /usr/bin/konsole -e /home/rollo/scripts.script.sh
If I put /usr/bin/konsole at the start of the script, then (with or without the export variable line) cron runs konsole. But I have no idea how to get the script to 1) open konsole, and then 2) run a script within the same konsole. Which is why I wanted to use konsole -e script.

Any ideas where next?
 
Old 11-10-2006, 01:56 PM   #6
rollo
Member
 
Registered: Apr 2004
Location: France
Distribution: Debian Sid (Kanotix)
Posts: 237

Original Poster
Rep: Reputation: 30
Thumbs up Solved

Found the solution. To get cron to run the X app Konsole correctly, add the display switch to the command. Like this:

Code:
/usr/bin/konsole -display :0.0 -e /path/to/script
Thanks unSpawn for the pointer.

Rollo
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Seting cron to run a script every second Rinish Programming 14 09-23-2010 02:48 AM
cannot get tu run a php script in cron alain Linux - General 6 02-06-2006 02:54 AM
FTP Script will not run from Cron grhansen Programming 12 01-13-2006 04:13 AM
run shell script on cron varunbihani Linux - Newbie 5 07-08-2005 01:50 AM
can't get cron to run my script. dr_zayus69 Linux - Software 6 04-12-2005 06:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:59 PM.

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
Open Source Consulting | Domain Registration