Hello all, I'm trying to set up a cron job to start Deluge when my off peak quota is operating (twixt 2am and 10am). I used the info on the Deluge Wiki with Gnome-Schedule but I can't get it to start Code: 0 2 * * * deluge -u console -a "config --set max_active_limit 100" Code: 0 10 * * *deluge -u console -a "config --set max_active_limit 0" Can anyone see anything wrong with that code, and what needs to be working (other than the machine!!!) for it to start?
is that in user crontab, or system crontab ? If it's in system crontab, you should have a user before the command.
First up, you must specify the full path to programs listed in cron, ie: instead of "transmission", you'd use "/usr/bin/transmission". Secondly, if it's a GUI app, then you need to specify the display for it to start on. This is how I start Transmission with a cron job: Code: 0 0 * * * DISPLAY=:0 /usr/bin/transmission %F & ...will start it at midnight on the first X display. The ampersand on the end tells cron not to wait for Transmission to return an exit code (ie: don't wait for the program to quit - start it as a background process). Editing a specific user's crontab can be achieved with: Code: $ sudo crontab -u jbloggs -e ...which will edit jbloggs' crontab. If you just say "sudo crontab -e" you will edit root's crontab instead.
OK HyRax1, I'm away It starts the GUI, but there are some error messages in the terminal, viz Code: close failed in file object destructor: Error in sys.excepthook: Original exception was: /var/lib/python-support/python2.6/deluge/ui/gtkui/mainwindow.py:63: GtkWarning: gtk_toolbar_set_icon_size: assertion `icon_size != GTK_ICON_SIZE_INVALID' failed "glade/main_window.glade")) This doesn't seem to affect the program operation. I got lazy and used the scheduler - the only change to your suggestion was I had to use a | instead of the % To stop it at 10 am, is it the same syntax, or is there another parameter to terminate the program? TIA
Perfectly normal. Not every iconset in every theme is perfect. Two ways to do it. If the program is properly written, it should respond and shutdown cleanly with: Code: $ killall <program name> eg: $ killall transmission ...which should be the same as clicking the close button of that program's GUI with your rodent. Unfortunately some programs don't respond politely and are a bit stubborn. For these programs you can be a bit more forceful with the "kill" command. Code: $ kill <program pid> ...should do the same as killall, which for a stubborn program isn't likely to be much. To terminate with extreme prejudice, use: Code: $ kill -9 <program pid> ...which no application can stop (muhahahahahaaaaa). To get a program's PID (Process ID), use the command: Code: $ ps aux | grep <program name> ...and look at the left-most number. That's the PID. If you want to get really classy and get the PID and feed it to the kill command in one line, check out my blog entry about it, but in short: Code: $ ps -eo pid,args | grep <program name> | awk '{print $1}' | xargs -I {} kill -9 {} EDIT: Incidentally, I'm using Deluge now as well instead of Transmission. My crontab looks like this: Code: # Start the Deluge BitTorrent daemon at midnight and the web UI one minute later (since it seems to have issues starting when there's no daemon running first). 0 0 * * * /usr/bin/deluged & 1 0 * * * /usr/bin/deluge --ui web & # Terminate the Deluge BitTorrent daemon at midday to prevent using peak quota. # Note that the web UI keeps running but can't operate without the daemon. 0 12 * * * killall deluged I don't use the GTK interface - my Deluge runs on my headless server and I control it via the (rather cool) Ajax web interface.
Awesome, works a treat! Thanks again HyRax1 - as usual informative, and with teh bonus educational aspect at no charge!
Please don't encourage the use of "kill -9" Programs catch exit signals for a reason, and "kill -9" is like shutting down your computer by yanking the power plug.
I know, I've just seen too many trigger happy people SIGKILLing everything in sight and then wondering why everything is corrupted and buggered
Geez, I didn't expect to start a sort of Spanish Inquisition! I went with the "killall deluge" command, and it seems to have done the trick without any issues. BTW, what's the diff between deluge and deluged?
deluged is the daemon that actually does the work of downloading torrents. deluge is just the user interface to the daemon.
So the go to make it run without the GUI is to use the "deluged" command? Not that the GUI imprisons a heap of cpu cycles anyway.