[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Using crontab to update Debian



I wrote:
>> Here is another, much simpler, and probably better, idea.  Stay up 
>> late one night and start "apt-get dist-upgrade" yourself, and once
>> downloading starts, go to sleep.  Use cron or at to automatically 
>> hang up the phone when the expensive rates begin again.  (i.e., just
>> put "poff" in the script that runs at 6am, or whenever.)

Paulo Henrique Baptista de Oliveira wrote:
>     The problem is that I dont want to stay wake up until 12:00 
> tonight. I like to sleep early

Jason Gunthorpe wrote:
>
> apt-get -yfqq update
> apt-get -dyfqq dist-upgrade
> 
> Is the best way to run it from cron, run it again without the options
> during the day to install it
>

So, now it seems you have your answer!  Use the crontab script
you had before, adding the options listed by Mr. Gunthorpe.  That
solves the "staying up 'till midnight" problem.  You can use
another cron job to automatically kill the connection at 6am
(with poff).

You might have to do it again the next night if not everything
was retrieved in one night.

Paulo Henrique Baptista de Oliveira wrote:
> 
> Do you know if there is a manner to reconect if the connection 
> goes down and re-run apt-get?
>
> Better, is there a a possibility to detect if the connection goes 
> down, reconnect and run apt-get again?
>

I wish I had my Debian system handy so I could be more specific... 
perhaps my comments will spur someone else into giving more details if
anything I'm going to say is unclear/misleading/wrong/stupid.

When you run pon, it creates a file somewhere under /var that contains
the process id of ppp.  IIRC, it is /var/run/ppp.pid

When you run poff, it looks in this file to see which process should be 
killed.  You can probably find the name & location of this file with 
"man pon" if it isn't /var/run/ppp.pid.  (It might be ppp0.pid)
You could also just look in /var/run when you are connected.

You could write a little script that checks if this file is still
there.  If it isn't, the script could restart the connection and
apt-get, which will be smart enough to pick up where it left off.
You can run this script with cron as well.

A first stab at it could be:

while true;
do
  sleep 1200
  test -f /var/run/ppp.pid || <your-apt-get-script>
done

This will (or at least, it should!) run <your-apt-get-script> if
the file /var/run/ppp.pid doesn't exist.

To avoid it reconnecting after 6am, you might add a simple counter
so that it only executes 18 times.  (18 since you want to be connected
for 6 hours, and this sleeps for 20 minutes (1200 seconds) -- if it runs 
18 times, it has run for 6 hours.)

Kirk


Reply to: