【树莓派】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下的批处理相似,也就是用各类命令预先放入到一个文件中,方便 ...
随机推荐
- Java Calendar,Date,DateFormat,TimeZone,Locale等时间相关内容的认知和使用(5) SimpleDateFormat
本章介绍SimpleDateFormat. SimpleDateFormat 介绍 SimpleDateFormat 是一个格式化Date 以及 解析日期字符串 的工具.它的最常用途是,能够按照指定的 ...
- 【Devops】【docker】【CI/CD】2.docker启动jenkins环境+安装必要的插件
[注意:]jenkins的docker镜像,需要从官网进入直接获取,其他地方获取到的docker镜像,可能因为Jenkins版本过低,导致后续插件安装失败等问题!!! ================ ...
- Java 正则表达式格式化时间显示
/* * test.java * Version 1.0.0 * Created on 2017年12月16日 * Copyright ReYo.Cn */ package reyo.sdk.util ...
- 危机边缘第五季/全集Fringe迅雷下载
本季Fringe Season 5 第五季(2012)看点:Walter 用琥珀将Olivia.Peter.Astrid和自己封存,以便在2036年的未来世界实现自己抵抗观察者的完美计划,“解冻”后的 ...
- Easyui numberbox获取焦点事件
Html文件: <input id="auctionBrandNoGetByHand" style="width:160px;" class=" ...
- npm ERR! Error extracting ~/.npm/cloudant/1.9.0/package.tgz archive: ENOENT: no such file or directory, open '~/.npm/cloudant/1.9.0/package.tgz'
修改package.json Thanks machines returning the above error when , just and now all the builds are pass ...
- JMap与JStack
用JMap和JStack做堆dump和线程dump 命令 1. jmap -dump:format=b,file=filename pidjmap -dump:format=b,file=jmap02 ...
- jboss中控制台jmx-console 登录的用户名和密码设置
默认情况访问 http://localhost:8080/jmx-console 就可以浏览jboss的部署管理的一些信息,不需要输入用户名和密码,使用起来有点安全隐患.下面我们针对此问题对jboss ...
- 如何远程运行PowerShell命令?
首先, 被remote运行PowerShell的windows必须已经join了domain. 其次, 该Windows的PowerShell必须开启对remote command的接受, 运行下面的 ...
- Wildcard Matching leetcode java
题目: Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single charact ...