Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

A few releases ago (lucid lynx) I wrote a backup shell script task that was executed as an anacron job every week. It worked fine then. However, It fails in natty.

The idea was simple. The script referenced by the anacron job just launched gnome-terminal with the actual backup script passed in as the argument. So a new terminal window popped up showing the script output.

Here you are my anacron file: http://paste.ubuntu.com/673965/
and here, the launcher: http://paste.ubuntu.com/673963/

Any idea about why what once worked, stopped working? And more important, what to do to make it work again?

Note: I would appreciate tested solutions when possible...

share|improve this question
    
Do you have some errors to show? What if you run the launcher from a virtual terminal, say tty1? –  enzotib Aug 24 '11 at 17:13
    
I'll show them tomorrow, but I think it has to do with my DISPLAY variable setting...though it worked on lucid –  zuzust Aug 24 '11 at 17:22
    
You should not launch graphical applications (gnome-terminal) from a cron job, cron jobs are used for batch (non interactive) tasks. –  João Pinto Aug 24 '11 at 17:34
    
The thing is that I want the user to be aware of the execution of the backup job, and want her to see the task ouput while it is being executed. How would you do that? –  zuzust Aug 24 '11 at 18:06
    
For that you should use some GUI alarm application which allows to execute commands. –  João Pinto Aug 24 '11 at 18:54

1 Answer 1

Third
You could call the gnome-terminal directly from anacron file, something like:

7 5 * * * env DISPLAY=:0 gnome-terminal -e "/home/carles/Admin/dotfiles/bin/jobs/backup/backup-reisender"

Second
Maybe we could try this "cheat":

bash -c "gnome-terminal -e '/home/carles/Admin/dotfiles/bin/jobs/backup/backup-reisender 0'"  

First
Once I could fix a similar problem by changing this:

gnome-terminal --command="/home/carles/Admin/dotfiles/bin/jobs/backup/backup-reisender 0"   

into this:

gnome-terminal -e "bash -c \"/home/carles/Admin/dotfiles/bin/jobs/backup/backup-reisender 0; exec bash\""  
share|improve this answer
    
What was the issue you had to fix? And, what's the reason for exec bash? Notice that backup-reisender is a bash shell script. Thanks in advance.. –  zuzust Aug 30 '11 at 16:38
    
The issue was a shortcut key combination that refuses to work unless I made the changes above. The "exec bash" was required also for the issue I had. This suggestion didn't work for you? –  desgua Aug 30 '11 at 23:59
    
Nop, it didn't work :( The issue has more to do with launching a GUI app like gnome-terminal... –  zuzust Sep 1 '11 at 9:59
    
May be we could try the other way around? I've updated the answer. –  desgua Sep 1 '11 at 12:13
    
Maybe calling the graphical environment from anacron as suggested here: help.ubuntu.com/community/CronHowto#GUI_Applications –  desgua Sep 2 '11 at 1:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.