August 7, 2007 @ 15:19
Script for GUI Linux Job Scheduling
![]() |
If you need to start some gnu/linux app under console then great at command comes to the rescue, and it is easy to use.
But if you have a need to start some GUI app under KDE or Gnome than just issuing at command can’t do it by itself.
I wanted to have some apps start on my desktop before I come to work and sit at the desk. I also close some apps at 16:15h as I work until 16h.
Closing apps is easy because I just used gnome-schedule which is a frontend to cron with command "pkill firefox" to shutdown firefox at given time.
Starting apps is a bit more tricky because all cron scripts are run under root privileges and I need an app to start under regular desktop user privileges.
With some help from fedora-list mailinglist I got this script:
================== cut ===============
#!/bin/bash
#
# A script to create a script to run GAIM at 8:15 am.
#
script_file=~/start-gaim.sh
if [ -z $XAUTHORITY ] ; then
echo XAUTHORITY in not set!
exit 1
fi
if [ -z $DISPLAY ] ; then
echo DISPLAY is not set!
exit 1
fi
echo \#\!/bin/bash > $script_file
echo export XAUTHORITY=$XAUTHORITY >> $script_file
echo export DISPLAY=$DISPLAY >> $script_file
echo gaim >> $script_file
chmod +x $script_file
at -f $script_file 8:15 am
================== cut ===============
The only drawback is that I need to start this script every day under my username in order to have gaim start the next morning at 8:15am.
Do you have some idea how to make this work automatically every day? Do you have some other ideas how to do this in some other way? Please post your ideas as comments.
Filed under english, linux Permalink
6 Comments »
RSS feed for comments on this post

Posted by mark0
August 7, 2007 @ 23:39
su -c ’skripta’ pero ?
Posted by Rohit Jain
August 9, 2007 @ 14:04
kewl…. this is surely a cool script… thanks
Posted by Joe
November 14, 2007 @ 23:01
I’m not too familiar with the at command, but I think that if you don’t want to rerun that script every day, putting this line into your ~/start-gaim.sh script should work:
at -f 8:16 am
this will resubmit your above script at 8:16, with 23:59 to go until starting gaim again.
Posted by wwp
January 2, 2008 @ 17:52
You could use your user’s crontab for this (`crontab -e` to edit crontab’ed jobs, `crontab -l` to list them), and even to start gaim.
Posted by valent
January 11, 2008 @ 17:51
crontab doesn’t start gui apps :(
I wrote crontab entry for pidgin and it doesn’t work:
$ crontab -l
50 * * * * pidgin
it was 17:48 so I tested if it will start at 17:50 and it didn’t.
Posted by vlada
January 21, 2008 @ 13:47
Just cron that shell script instead, should work