linux定时任务
来源:互联网 发布:php 返回上个页面 编辑:程序博客网 时间:2024/05/16 08:53
先对sh脚本赋予权限,如果是dos编码还要转为unix:
vi 文件名
:set fileformat=unix
:w
如果没有crond先安装:
yum install crontabs
添加定时任务有两种方式:
1) 系统级别添加
vi /etc/crontab
添加
/2 * * * root /opt/TRS/sh/mariadbBackup.sh
2) 针对当前用户添加
crond -e
进入vi操作:
SHELL=/bin/bash
/2 * * * root /opt/TRS/sh/mariadbBackup.sh
重启:
/sbin/service crond restart
使用命令查询crontab 任务时,一直提示:no crontab for root 。查看了一些资料,说是crontab在初始时,设置了一次编辑方式,所以试了一下crontab -e的方式编辑,即在命令行,输入 crontab -e ,进行编辑页面,输入定量执行的脚本:
/2 * * * root /opt/TRS/sh/mariadbBackup.sh
crontab -e的使用方式与vi编辑器相同, 配置成功后 使用命令crontab -u root -l 可以查看当前定时任务
具体流程:
cd etc
在etc目录下,执行
crontab -e
在插入模式下输入 :
/2 * * * root /opt/TRS/sh/mariadbBackup.sh
保存
使用命令 crontab -u root -l 可以查看当前定时任务 成功!
crontab命令详解
usage: crontab [-u user] file
crontab [ -u user ] [ -i ] { -e | -l | -r }
(default operation is replace, per 1003.2)
-e (edit user’s crontab)
-l (list user’s crontab)
-r (delete user’s crontab)
-i (prompt before deleting user’s crontab)
- linux 定时任务 定时访问
- Linux定时执行任务
- linux 定时任务 crond
- Linux定时任务
- linux crond 定时任务
- linux定时任务cron
- Linux 定时任务
- linux下定时任务
- linux 定时任务
- linux 定时任务
- linux定时任务
- Linux定时任务
- Linux Crontab 定时任务
- Linux 定时任务 crontab
- linux定时任务
- Linux定时任务设置
- Linux定时任务
- linux 定时任务
- git常见命令
- Resnet学习笔记(四)--train_imagenet.py
- CTEX的一些常用技巧
- 如何用ps制作苹果
- 给定一个数判断是否为2的幂
- linux定时任务
- mapreduce实现writable接口自定义输出格式
- Dynamic Columns
- 解决windows adb 脆弱的问题
- OpenCV手写数字字符识别(基于k近邻算法)
- redis本地连接远程报错
- 数据结构之二叉树
- Flask使用总结
- 浏览器HTTP缓存机制