【树莓派】crontab设置Linux设备定时重启
简介:设置Linux设备定时重启或者关机
问题:有台设备每天总需要使用的人手动重启一下才可以正常工作,但是检查了日志,看起来服务一切都正常。时间和正确时间相差4mins。
解决办法:
1.增加定时任务,设置自动重启;
2.修改正确时间,并增加自动同步;
都是相对比较简单的命令,这里简单记录一下,可以供需要的同学参考;
增加定时任务,设置自动重启:
编辑crontab:
sudo crontab -e
增加定时重启命令,查看crontab
lifeccp@raspberrypi:~ $ sudo crontab -l
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
0 10 * * * sudo -u root reboot
重启服务确保生效:
sudo service cron restart
sudo vi /etc/sudoers
其他:
需要root权限才能执行的crontab,比如shutdown关机 需要: sudo crontab -e
在编辑器中加入下面2行,先将时间记录到日志中,每天22点30分钟 执行关机命令,1分钟警告后会自动关机
30 22 * * * date >> /home/haochuang/temp/shutdown.log
30 22 * * * sudo -u root shutdown -h 1
</END>
【树莓派】crontab设置Linux设备定时重启的更多相关文章
- 设置linux服务器定时与时间服务器同步
在一些大公司经常出现这样一个情况:公司或一些机关单位的内部业务系统的应用服务器以及数据都是做的多机集群部署而且基本都是linux系统,而且都是内部网,不与外网通讯的.这样经常就会出现一个情况,我发送任 ...
- 使用python crontab设置linux定时任务
熟悉linux的朋友应该知道在linux中可以使用crontab设置定时任务.可以通过命令crontab -e编写任务.当然也可以直接写配置文件设置任务. 但是有时候希望通过脚本自动设置,比如我们应用 ...
- 详解使用python crontab设置linux定时任务
熟悉linux的朋友应该知道在linux中可以使用crontab设置定时任务.可以通过命令crontab -e编写任务.当然也可以直接写配置文件设置任务. 但是有时候希望通过脚本自动设置,比如我们应用 ...
- 【linux】【tomcat】linux下定时重启tomcat
步骤: 一.创建脚本文件,本脚本文件用于停止,重启tomcat运行的java进程,并设置脚本文件权限 1.新建脚本文件tomcat.sh [注意文件创建的路径] [查看当前路径的命令: pwd] ...
- 【linux】【tomcat】linux下定时重启tomcat 【CentOS 6.4】【CentOS 7.6】
本章内容以CentOS 6.4 和 CentOS 7.6 两个版本为例.[6和7的命令不同] 转载 :https://www.cnblogs.com/sxdcgaq8080/p/10730 ...
- linux下定时重启tomcat
工具/原料 linux tomcat 方法/步骤 编写tomcat_shutdown.sh: #!/bin/sh export JAVA_HOME=/home/oracle/jdk1..0_67/ e ...
- Linux每天定时重启Tomcat服务
1:查看crond 服务状态(确认Linux任务计划服务开启) service crond status crond (pid 1937) is running... 2:编写重启Tomcat的sh ...
- linux系统定时重启tomcat
#touch auto-start.sh [root@Linux opt]# echo $LANGen_US.UTF-8 #vim auto-start.sh #!/bin/sh export LAN ...
- linux定时重启tomcat服务的脚本学习
要求:在linux中定时重启一个tomcat服务 一:shell脚本即Shell Script [1],Shell脚本与Windows/Dos下的批处理相似,也就是用各类命令预先放入到一个文件中,方便 ...
随机推荐
- C#中的Hashtable
richTextBox1.Text = ""; Hashtable ht = new Hashtable(); ht.Add("); ht.Add("); ht ...
- Python:日期和时间类型学习
背景 在非开发环境经常需要做一下日期计算,就准备使用Python,顺便记下来学习的痕迹. 代码 1 # coding = utf-8 2 3 from datetime import * 4 5 ## ...
- Mac上 python 找不到 yaml模块
(1) yaml http://codyaray.com/2011/12/pyyaml-using-easy_install-on-mac-os-x-lion 1.报错 ImportError: N ...
- 猫都能学会的Unity3D Shader入门指南(二)
关于本系列 这是Unity3D Shader入门指南系列的第二篇,本系列面向的对象是新接触Shader开发的Unity3D使用者,因为我本身自己也是Shader初学者,因此可能会存在错误或者疏漏,如果 ...
- itunes connect 改版后无法访问的处理办法
很悲剧,今天要提交版本,结果itunes connect改版,然后进不去了, 限于无限loading- 是网速慢吗?再等等,先吃个饭,待会再来看- ------------------------ ...
- hydra 安装和使用
udo add-apt-repository ppa:pi-rho/security sudo apt-get update sudo apt-get install hydra hydra -l r ...
- html table奇偶行颜色设置 (CSS选择器)
:nth-child(n) 选择器匹配属于其父元素的第 N 个子元素,不论元素的类型.n 可以是数字.关键词或公式. 下面的例子, 设置表格的奇偶行背景颜色不同:单独设置表格的第1列背景颜色不同. & ...
- linux中断
[一].中断底半部 1. 软中断 --->>> 执行在中断上下文 --->>> 会被中断打断,不会被软中断或进程打断 --->>> ...
- Three.js中如何显示帧速【转】
https://blog.csdn.net/hannahlwh1988/article/details/36876295 Step1:src中添加: <script src="js/s ...
- ofstream的使用方法--超级精细。C++文件写入、读出函数(转)
ofstream的使用方法ofstream是从内存到硬盘,ifstream是从硬盘到内存,其实所谓的流缓冲就是内存空间; 在C++中,有一个stream这个类,所有的I/O都以这个“流”类为基础的, ...