• 读者文摘
  • 美文摘抄
  • 短文摘抄
  • 日记大全
  • 散文精选
  • 感恩亲情
  • 人生感悟
  • 智慧人生
  • 感悟爱情
  • 心灵鸡汤
  • 实用文档
  • 名人名言
  • 伤感文章
  • 当前位置: 蜗牛文摘网 > 感悟爱情 > BSD关机重启脚本/etc/rc.d/rc.0_etc rc.local

    BSD关机重启脚本/etc/rc.d/rc.0_etc rc.local

    时间:2020-02-14 08:35:03 来源:千叶帆 本文已影响

      BSD关机重启脚本/etc/rc.d/rc.0

      #!/bin/sh

      # 关闭所有程序

      echo "Sending all processes the TERM signal..."

      /sbin/killall5 -15

      sleep 1

      echo "Sending all processes the KILL signal..."

      /sbin/killall5 -9

      sleep 1

      # 卸载swap

      echo "Deactivating swap partitions..."

      /sbin/swapoff -a

      # 保存随想数种子

      echo "Saving random seed to a temporary file..."

      /bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2>/dev/null

      # 保存系统时钟

      echo "Saving the system time to hardware clock..."

      /sbin/hwclock --systohc --utc

      # 卸载远程系统

      echo "Unmounting remote filesystems..."

      /bin/umount -a -f -tnfs

      # -w参数并不会真的重开机,只是把记录写到 /var/log/wtmp 档案里

      # 0级和6级这里是一个文件,通过脚本名来判断是关机还是重启,所以有了下面结构。

      case "$0" in

      *6)

      /sbin/reboot -w

      ;;

      *0)

      /sbin/halt -w

      ;;

      esac

      # 以只读方式挂载系统

      echo "Remounting root filesystem read-only..."

      /bin/mount -n -o remount,ro /

      #将刷新缓存,保存数据

      echo "Flushing filesystem buffers..."

      /bin/sync

      #卸载本地文件系统

      echo "Unmounting local filesystems..."

      /bin/umount -a -tnonfs

      # 关机

      case "$0" in

      *6)

      echo "Please stand by while rebooting..."

      /sbin/reboot -d -f -i

      ;;

      *0)

      echo "Bye..."

      /sbin/halt -d -f -p

      ;;

      esac

    相关热词搜索:Linux教程BSD关机重启脚本 etc rc d rc 0screenrc bsdrc d

    • 名人名言
    • 伤感文章
    • 短文摘抄
    • 散文
    • 亲情
    • 感悟
    • 心灵鸡汤