# Free time scheduling in Ubuntu



## cool_techie_tvm (Mar 3, 2008)

Lets get the facts straight. Linux noob in here.

Ok, now here is my query. I schedule downloads during the free time (2am to 8am) on my windows installation. Here is how it works. By 2:10am i get connected (using rasdial). By 2:11am, utorrent starts downloading. By 7:55am the pc is shutdown. 

I want to do the something similar in Ubuntu. I connect by issuing _pon dsl-provider_. I have also installed _deluge torrent client_. 

Guide me fellas on how to schedule my downloads in Ubuntu  

This schedule thingy is the only fact thats preventing me from being on ubuntu full time.


----------



## mediator (Mar 3, 2008)

May be a shell script?


----------



## abhinandh (Mar 3, 2008)

try gnome-sheduler in the repos.it uses cron


----------



## Rahim (Mar 3, 2008)

^^ gnome-schedule


----------



## cool_techie_tvm (Mar 3, 2008)

Thanks guys. Ok i installed gnome-schedule. Now what? How do i set the connection to start at 2:10? How do i set deluge to start by 2:11am??


----------



## Rahim (Mar 3, 2008)

BTW i am getting this error
	
	



```
no crontab for rahim
```
 while scheduling anything.


----------



## cool_techie_tvm (Mar 3, 2008)

The link mentioned, gives the procedure for installing gnome-schedule. I have already done that.


----------



## Rahim (Mar 3, 2008)

^as you can see from my post, we both are in the same boat.
Hope someone guide both of us.


----------



## ray|raven (Mar 3, 2008)

Check if you have cron running in the list of processes.
Also check this link, *kevin.vanzonneveld.net/techblog/article/schedule_tasks_on_linux_using_crontab/

Regards,
ray


----------



## mehulved (Mar 3, 2008)

rahimveron said:


> Found thisHOW TO: Gnome-Schedule
> BTW i am getting this error
> 
> 
> ...


what does the command 

```
crontab -l
```
return. Does it return the same?


----------



## Rahim (Mar 3, 2008)

I get that error using gnome-schedule through The Terminal.
BTW here is what i get of *crontab*

```
user@HOST:~$ crontab 
crontab: usage error: file name must be specified for replace
usage:  crontab [-u user] file
        crontab [-u user] { -e | -l | -r }
                (default operation is replace, per 1003.2)
        -e      (edit user's crontab)
        -l      (list user's crontab)
        -r      (delete user's crontab)
```


----------



## mehulved (Mar 3, 2008)

So, your crontab is working. Just check gnome-schedule's settings, maybe since you seem to have compiled it. It's looking for crontab in the wrong place.


----------



## Rahim (Mar 3, 2008)

^^ I installed it through the repo.
the Preferences option is greyed-out even when i start it with sudo.


----------



## ray|raven (Mar 3, 2008)

mehulved said:


> So, your crontab is working. Just check gnome-schedule's settings, maybe since you seem to have compiled it. It's looking for crontab in the wrong place.



AFAIK, Gnome-Schedule wont compile if it cant find crontab.


----------



## gary4gar (Mar 3, 2008)

its easy as pie, no need to install any extra packages, cron itself is very powerful.

my crontab looks like


```
# m h  dom mon dow   command
10 2 * * * cd /home/gaurish/scripts && sh router-reboot.sh | telnet
10 2 * * * DISPLAY=:0.0 /opt/azureus/azureus
13 2 * * * wget -ci /home/gaurish/dl-list.txt
50 7 * * * cd /home/gaurish/scripts && sh router-reboot.sh | telnet
```

Root's crontab

```
50 7 * * * /sbin/shutdown -h 0
```


----------



## ray|raven (Mar 3, 2008)

gary4gar said:


> _its easy as pie, no need to install any extra packages, cron itself is very powerful._
> 
> my crontab looks like
> 
> ...



Thats why i gave them that link 

Btw, why use cd? just give the link to the script.


----------



## cool_techie_tvm (Mar 3, 2008)

I understand from gary4gar's post that he has created scripts to automate the whole procedure. Am curious of these scripts. How to create custom scripts in ubuntu? If i can create them, then its easy to schedule them using crontab.


----------



## mehulved (Mar 3, 2008)

scripts? You mean shell scripts?


----------



## cool_techie_tvm (Mar 3, 2008)

^^ well i guess so, told u am a noob as far as linux is concerned...


----------



## praka123 (Mar 3, 2008)

THIS post shows how!
*www.thinkdigit.com/forum/showpost.php?p=681714&postcount=97

I think u guys can browse tips and tricks in OSS Sticky thread


----------



## cool_techie_tvm (Mar 3, 2008)

Wohoo !! I succeeded in automating the whole process..i tested it and its working fine... here is my crontab 


```
10 2 * * * pon dsl-provider  # BSNL Connect, 
11 2 * * * DISPLAY=:0.0 /usr/bin/deluge # Deluge, 
55 7 * * * poff dsl-provider # BSNL Disconnect,
```

Thanks to everyone, especially to prakash for pointing me to the right thread..


----------



## praka123 (Mar 3, 2008)

^congrats


----------



## Rahim (Mar 3, 2008)

Thanks praka bhai tusi great ho!!!
It was so easy( after getting the guidance here).


----------



## abhi_10_20 (Mar 21, 2008)

bump 

Could you help me out in doing all these with crontab:

1. hibernate(off)- 12:15 am
2. power on- 2 am
3. dsl on- 2 05 am
4. azureus on- 2 10 am 
5. azureus close- 7 45 am
6. dsl off- 8 am
7. hibernate(off)- 8:05 am

can we automate all these?


----------



## abhinandh (Mar 21, 2008)

abhi_10_20 said:


> bump
> 1. hibernate(off)- 12:15 am
> 2. power on- 2 am


those two need to be done from the BIOS.
search for scheduling featres in your BIOS if they exist.



> 3. dsl on- 2 05 am
> 4. azureus on- 2 10 am
> 5. azureus close- 7 45 am
> 6. dsl off- 8 am
> 7. hibernate(off)- 8:05 am


they can be configured from gnome-schedule(install it from repos)
or you can do it through CLI as mentioned above in this thread.


----------



## mehulved (Mar 21, 2008)

You maybe able to use *ubuntuforums.org/showthread.php?t=329902 for 1 and 7
for 3 to 6

```
crontab -e
```
It will open a file, it should look like this


> 5 2 * * *    pon dsl-provider
> 10 2 * * *  env DISPLAY=:0. azureus
> 45 7 * * *  killall -HUP azureus
> 0   8 * * *  poff dsl-provider


I am assuming you use pon, poff for connection and disconnection
I don't have azureus or ubuntu so I don't know the path to azureus, it would be a better idea to give the whole path.
And reading the appropriate man pages would have provided you all these answers
Or a search on your favourite search engine.
Only thing I have no idea about is how to automatically wake up from hibernate.

Also, see *ubuntuforums.org/showthread.php?t=313884 for query #2


----------



## abhi_10_20 (Mar 21, 2008)

thanks.... from what i learnt, its impossible to auto power on using crontab...bcoz cron itself needs a manual system start to up and run. So....only thing left out is by the BIOS.... i explored there....but dint find any option like that... only had 'wake on lan' but my comp is not connected to any lan......any other ideas ?


----------



## Vivek788 (Apr 25, 2008)

hey i use crontab..and shutdown at 7.58 but as long as modem remains on..they take that much time as extra and divide total usage by time..i lost abt 800mb this month..help


----------

