![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
Hello, Unregistered You are browsing a READ only archive of the main support categories pre 4/21/2008. You will not be able to post or reply any threads in this section.
Ubuntu 9.10 is out!!!
When downloading Ubuntu 9.10 please consider using bittorrent to get your copy of Ubuntu. The Ubuntu Developers Summit for Lucid Lynx will be held the week of 16-Nov-2009 till 20-Nov-2009 in Dallas, TX USA. Visit the the Ubuntu wiki for more information about UDS and how to participate remotely. |
|
General Help All your general support questions for Ubuntu, Kubuntu, Edubuntu and Xubuntu. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
5 Cups of Ubuntu
![]() Join Date: Oct 2006
My beans are hidden!
|
Trouble scheduling task
Hey guys,
I'm kinda a newbie to linux, but I'm trying to figure everything out. I've been working for a while on this one thing and I'm not having much luck, maybe someone here can help! I want to schedule the computer to be locked down every 2 days...So I tried to use anacron to run gnome-screensaver-command -l, no dice. I think this is because anacron runs everything as root, and the command needs to be run by me (it works from the terminal when I run "gnome-screensaver-command -l"). I tried using sudo -u to run it as my username, but this doesn't even work from the terminal. It says "Sorry, user zac is not allowed to execute '/usr/bin/gnome-screensaver-command' as zac on ubuntu." ![]() Anyway, does anyone have some advice about this? Or an alternative method? Thanks! -Zac |
|
|
|
|
|
#2 | |
|
Ubuntu addict and loving it
![]() Join Date: Feb 2005
Location: Melbourne, Australia
Beans: 7,067
Ubuntu 9.04 Jaunty Jackalope
|
Re: Trouble scheduling task
Quote:
Do a search for running graphical X apps from cron, there should be numerous posts to solve the problem.
__________________
Regards, David. The Forum search function is useful for immediate help (give it a try).
Please mark your thread as "Solved" (using the Thread Tools) when appropriate. |
|
|
|
|
|
|
#3 |
|
Ubuntu addict and loving it
![]() Join Date: Jul 2005
Location: Hughenden, Australia
Beans: 4,089
Ubuntu 9.04 Jaunty Jackalope
|
Re: Trouble scheduling task
Yes puffyzacd, dcstar is right, you need the export variable, check this link out, crontab: How to run GUI programs with cron
It works for me, my computer wakes me up every morning with Totem Movie Player playing a music file for me, I set it up with crontab. I used to need to boot into KDE before that, for Kalarm. Regards, Herman
__________________
Illustrated Dual Boot Site | GRUB Page | GRUB II Pages | LiLo Page | GAG Page | Super Grub Disk Page |
|
|
|
|
|
#4 |
|
5 Cups of Ubuntu
![]() Join Date: Oct 2006
My beans are hidden!
|
Re: Trouble scheduling task
Thanks for the help both of you, I think this solved one of the problems I'm having.
However, I'm still having trouble running this job. I made a test crontab file which looks like this: Code:
* * * * * export DISPLAY=:0 && /usr/bin/gnome-screensaver-command -l Thanks again for your help! -Zac |
|
|
|
|
|
#5 |
|
Ubuntu addict and loving it
![]() Join Date: Jul 2005
Location: Hughenden, Australia
Beans: 4,089
Ubuntu 9.04 Jaunty Jackalope
|
Re: Trouble scheduling task
Well I have been trying for hours now and you're right, it runs fine from a regular terminal, but I can't seem to get it to run from crontab either.
I have other tasks running from crontab, so we should be able to get this one running to (eventually). I tried editing /etc/crontab and running it from my username and as root, neither worked. I tried making a script with the command: gnome-screensaver-command -l in it too, and running that from crontab to I can run the command indirectly. That didn't work either. The script itself works okay whenever I run it the normal way. I did also try something blindingly simple that works fine! I went 'System'-->'Administration'-->'Screensaver', and opened the Screensaver Preferences window. There I marked the box for 'Activate the screensaver when the computer is idle', with an X. I also marked 'Lock screen when screensaver is active' That was a simple way to get the screen to lock, but it's only possible to set the timer for it for between one minute and two hours, not two days. However, it does seem to at least partially satisfy your requirements. SO far I have been unable to come up with anything better. Regards, Herman
__________________
Illustrated Dual Boot Site | GRUB Page | GRUB II Pages | LiLo Page | GAG Page | Super Grub Disk Page |
|
|
|
|
|
#6 |
|
5 Cups of Ubuntu
![]() Join Date: Oct 2006
My beans are hidden!
|
Re: Trouble scheduling task
Thank you Herman for all your hard work! I only wish we had more to show for it.
My subsequent efforts have proved fruitless as well, so I think I'm about ready to give up on gnome-screensaver-command and start looking for an alternative way to get something like this up-and-running. I'll come back and leave a post if I figure something out. -Zac |
|
|
|
|
|
#7 |
|
Ubuntu addict and loving it
![]() Join Date: Jul 2005
Location: Hughenden, Australia
Beans: 4,089
Ubuntu 9.04 Jaunty Jackalope
|
Re: Trouble scheduling task
Yes, me too ' I'm still trying, I'm reading the man page for the 'at' command right now, The 'at' command looks a bit promising so far....
Maybe the 'at' command is what we're looking for.
__________________
Illustrated Dual Boot Site | GRUB Page | GRUB II Pages | LiLo Page | GAG Page | Super Grub Disk Page |
|
|
|
|
|
#8 |
|
Ubuntu addict and loving it
![]() Join Date: Jul 2005
Location: Hughenden, Australia
Beans: 4,089
Ubuntu 9.04 Jaunty Jackalope
|
Re: Trouble scheduling task
YAY!
![]() I think I have made a step in the right direction, I used the 'at' command to schedule my shell script to run our '/usr/bin/gnome-screensaver-command -l' command and it seems to be working well for me! Here is an example of my shell script (probably most of us already know, but just for the benefit of those who might not be sure), 1. Open a blank gedit text editor page and name it 'lockscreen.sh'. Code:
sudo gedit lockscreen.sh Code:
#!/bin/bash /usr/bin/gnome-screensaver-command -l Make it executable, (by giving it the right file permissions) Code:
sudo chmod 0755 lockscreen.sh Code:
at 14:00 < lockscreen.sh I have tested that a few times already, now all we need to do is get is practice with it some more and learn how to set it to any times and dates we like. To see what time formats the 'at' comamnd will accept we need to read the file: /usr/share/doc/at/timespec, Code:
cat /usr/share/doc/at/timespec ![]() Regards, Herman
__________________
Illustrated Dual Boot Site | GRUB Page | GRUB II Pages | LiLo Page | GAG Page | Super Grub Disk Page |
|
|
|
|
|
#9 |
|
make bzImage, not war
![]() |
Re: Trouble scheduling task
The cron system has a very limited environment. When you call a program from a cron script, then you always have to supply the full path.
The at system is different, it runs with the environment of the user that called it. Cheers, Herman |
|
|
|
|
|
#10 |
|
Ubuntu addict and loving it
![]() Join Date: Jul 2005
Location: Hughenden, Australia
Beans: 4,089
Ubuntu 9.04 Jaunty Jackalope
|
Re: Trouble scheduling task
Hey, thanks Herman!
Do you know how to program this to run every two days? I am still trying to work out how to do that part of it now. So far I have made another script and I named it: at_command.sh, it contains (as you might guess), an 'at' command that is supposed to in turn run the lockscreen script. Now, what I am testing is this, the at_command.sh script has two commands in it, one to activate the other script right away, and another command to re-activate its-self (recursively), at a given time interval. For example, Code:
#!/bin/bash at now < lockscreen.sh at now + 5 minutes < at_command.sh Do you think it will work? Regards, Herman
__________________
Illustrated Dual Boot Site | GRUB Page | GRUB II Pages | LiLo Page | GAG Page | Super Grub Disk Page |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|