To end a connection, use the supplied version of
/usr/lib/ppp/ppp-off.

Having tested the functionality of these two scripts, one must then write scripts that perform the various tasks. The script to collect email has been described before, and we will here assume it is located at /home/dirk/pop.

It is quite easy to make an extension to the above that only will establish a connection if outgoing email and news is present. Lets call it
/root/news+mail.cond, and keep in mind that the name of the outgoing news-spool must be updated to suit:

The only thing remaining is to specify when all this is going to happen. This is done using the command crontab -e
as root. Let us assume that we always want to exchange news and mail at 07:00 in the morning, and after that every 4th hour assuming there are outgoing email and news:

00 7 * * * /root/news+mail
00 11,15,19,23 * * * /root/news+mail.cond

Ensure that every component is tested well before you connect them together. One may later add several other tasks, such as adjustment of the time of day (using
ntpdate), and automatic update (mirroring) of locally maintained WWW and FTP files up to the ISP (using make and ftp).

ALT: Depending on ones preferences, it is also possible to turn the process upside down. Every time a PPP link is initiated, the script
/etc/ppp/ip-up will be started. One may here add whatever magic is required to start exchange of email and news. See man pppd for further detail.

ALT: It is also possible to automatically connect PPP whenever network traffic is detected. This is in many ways the more elegant solution, but it is quite dependent on a good configuration to avoid frequent (and costly) connections being made. More information can be found at: