【树莓派】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下的批处理相似,也就是用各类命令预先放入到一个文件中,方便 ...
随机推荐
- centos7虚拟机(vmware)通过U盘传文件
centos7虚拟机(vmware)通过U盘传文件 centos7虚拟机安装以后,WINDOWS给CENTOS7传文件,除了在CENTOS7安装SAMBA外,其实通过U盘也是可以的. CENTOS7对 ...
- 奇怪的问题,疑惑?不用的 User agent 居然gzip不一样?
问题描述: 使用同一款浏览器(Chrome Version 41.0.2272.118 (64-bit)),访问同一个地址:http://www.skhktown.com/hkcity/resourc ...
- Python index()方法
Python index()方法 Python 字符串 描述 Python index() 方法检测字符串中是否包含子字符串 str ,如果指定 beg(开始) 和 end(结束) 范围,则检查是否 ...
- 【tensorflow】1.安装Tensorflow开发环境,安装Python 的IDE--PyCharm
================================================== 安装Tensorflow开发环境,安装Python 的IDE--PyCharm 1.PyCharm ...
- cocos2d-x 真正的定时器之schedule
转载请注明,原文地址:http://blog.csdn.net/musicvs/article/details/8551066 正文: 1. 不调用update函数,调用自己的函数 其实原理是一样的, ...
- UITableViewCell图片视差效果
UITableViewCell图片视差效果 效果 源码 https://github.com/YouXianMing/Animations 细节 OffsetImageCell.m OffsetCel ...
- AutoCompleteTextView,MultiAutoCompleteTextView 用法举例
AutoCompleteTextView 按下去变红色 MultiAutoCompleteTextView(用逗号可以添加多个关键字) AutoCompleteTextView,MultiAutoC ...
- Jenkins 快速搭建
Jenkins 介绍 Jenkins 作为持续集成的重要工具,在DevOps整个工具链中有重要的地位.Jenkins 一般作为独立的应用运行在Java Servlet容器中如Jetty,也可以运行在其 ...
- Generalized normal distribution and Skew normal distribution
Density Function The Generalized Gaussian density has the following form: where (rho) is the " ...
- python模块uuid产生唯一id
使用版本4:uuid4就可以了 UUID4缺点:糟糕的随机数发生器使得它更有可能发生碰撞,但是概率真的很小 UUID1缺点:暴露隐私 If all you want is a unique ID, y ...