linux常用命令:关机重启命令

linux常用命令:关机重启命令,第1张

body{
line-height:200%;
}
linux常用命令:关机重启命令
关机重启命令相对来说是比较简单的命令,但也是相对重要的命令。
1shutdown命令
[root@localhost~]#shutdown[选项]时间
选项:
-c:取消前一个关机命令
-h:关机

可以定时关机
-r:重启

可以定时重启
我推荐大家使用shutdown命令关机重启?因为shutdown命令可以在关机重启之前正确的保存它正在启动的服务,我们都知道在关机重启之前保存服务,才能不会造成数据丢失。
为什么服务器不能直接断电?服务器正在高速运转,如果不采用正确关机重启就会导致硬件损坏。
2其他关机命令
[root@localhost~]#halt
[root@localhost~]#poweroff
[root@localhost~]#init
0
3其他重启命令
[root@localhost~]#reboot
[root@localhost~]#init
6
4系统运行级别
0
关机
1
单用户
2
不完全多用户,不含NFS服务
3
完全多用户
4
未分配
5
图形界面
6
重启

这里可以使用下面的命令
# crontab -e #这个表示编辑root用户的计划任务
点击i 后进入文件编辑状态,输入如下格式的一行
0 0 reboot #意思就是每天的12点00分执行系统重启的任务
同样你也可以打开另外一个文件进行编辑
# vi /etc/crontab
在文件末尾加入上面的一行
这样也可以实现。
这两个区别是在于第一个表示的是用户root的计划任务,而第二个则表示系统级别的计划任务,与用户没有什么关系。

contab 命令
crontab -e
0 0 4 <your_command>
# Example of job definition:
# ---------------- minute (0 - 59)
# | ------------- hour (0 - 23)
# | | ---------- day of month (1 - 31)
# | | | ------- month (1 - 12) OR jan,feb,mar,apr
# | | | | ---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# user-name command to be executed

一小时太频繁了。
一天足可以了。
1写个脚本
apcsh
========
#!/bin/bash
apactl
-k
restart
2增加权限
chmod
a+x
apc
3加入
Crontab
设定时间
一天
执行一次
4启动Crond
服务
service
crond
restart

可以用cron自动执行脚本

# Example of job definition:
# ---------------- minute (0 - 59)
# |  ------------- hour (0 - 23)
# |  |  ---------- day of month (1 - 31)
# |  |  |  ------- month (1 - 12) OR jan,feb,mar,apr 
# |  |  |  |  ---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
#          user-name command to be executed

23 root  /usr/local/

如上,/usr/local/ 为花生壳重启服务的命令


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/10289389.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-07
下一篇 2023-05-07

发表评论

登录后才能评论

评论列表(0条)

保存