home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume13 / backups / shutdown.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-01-31  |  810 b   |  48 lines

  1. static char rcsid[] = "$Header: shutdown.c,v 1.1 85/04/05 17:14:09 scooter Exp $";
  2.  
  3. /*
  4.  * shutdown
  5.  *
  6.  * This module controls the system shutdown message stuff.
  7.  */
  8.  
  9. #include    <stdio.h>
  10. #include    "backup.h"
  11.  
  12. shutdown(minutes)
  13. int minutes;
  14. {
  15.     char    temp[180];
  16.     FILE    *nlfl;
  17.  
  18. /*
  19.  * Begin by formatting the shutdown command
  20.  */
  21.  
  22.     sprintf(temp,"/etc/shutdown -k +%d %s",minutes,
  23.             "System going down for system backups");
  24.  
  25.     system (temp);
  26.  
  27. /*
  28.  * Now sleep until shutdown is complete
  29.  */
  30.  
  31.     sleep(minutes*60 + 5);
  32.  
  33. /*
  34.  * Since shutdown unlinks /etc/nologin when it exits, we must re-do it
  35.  */
  36.  
  37.     nlfl = fopen("/etc/nologin","w");
  38.     if (nlfl == NULL)
  39.     {
  40.         fprintf(stderr,"*** Warning: unable to disable logins\n");
  41.     } else {
  42.         fprintf(nlfl,"NO LOGINS: System backups in progress\n");
  43.         fflush(nlfl);
  44.         fclose(nlfl);
  45.     }
  46.  
  47. }
  48.