SchedHow to kill my net connection automatically?

G

Guest

Guest
I want to write a short command to kill my internet connection at 7am each morning, so that the phone line isn't tied up in the morning if I leave the computer downloading over night...

So far, I have come up with...

ps -C pppd -o "%p" | tail -1 | kill -HUP

which doesnt work...

why?

Once I have this command worked out I plan to put it in a Cron file...

The only clue I have so far is, that the input for kill is the pid of pppd, but with one space before it. I dont know how to get rid of this. Also, I dont know if kill can take a pid input through a pipe in this manner.

Please, someone help me... I wont be offended if you have a better, more elegant way of going about this ;) -- I started off with ps -e | grep pppd....

I doubt you'd need me to explain what I have so far, but maybe it will save the time of looking through man pages..

ps -C pppd -o "%p" (lista all processes called ppps, showing only thier PID)

tail -1 (takes input from pipe, outputs the last line -- the pid of pppd with a space infront)

kill -HUP (pid) (sends the process the hangup signal, so that it restarts, I dont want to kill pppd becuase I will want to connect again later no doubt ; )

Thanks heaps if you got this far without being thoroughly bored, and thanks even more if you can tell me what I'm doing wrong...

Michael Whiteman
 
G

Guest

Guest
Im not familiar with dialup connections.. but for me to turn off my net connection on my linux box i type "telinit 1" and then "telinit 3" to bring it back up. Not sure if you can do that with dialup..
 
G

Guest

Guest
I have never used a modem with linux, but if killing pppd will stop your connection, check to see if if has a pid file in /var/run. if it does, just put the following in your cron script:
kill -HUP `cat /var/run/pppd.pid` - note that the ` is the one on the top left of the keyboard.

Cheers

I have not yet begun to procrastinate.
 
G

Guest

Guest
My previous problem can be solved by a simple...

ifdown ppp0 (interface ppp0 down), so if anyone wants to disconnect at certain times or anything, that's how.

ifup ppp0 will connect..

but, my new dillema..

I would like to make a script so that I can kill a task by name, not pid, it also needs to be able to handle when there is more than one process with that name... (this is where my previous attempt makes a little sense..)