日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > linux >内容正文

linux

linux 7 定时任务设置,centos7 配置crontab定时任务

發(fā)布時(shí)間:2024/9/27 linux 175 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux 7 定时任务设置,centos7 配置crontab定时任务 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1. 啟動(dòng)cron服務(wù)

# 查看服務(wù)狀態(tài)

systemctl status crond

# 啟動(dòng)

systemctl start crond

# 停止

systemctl stop crond

# 重啟

systemctl restart crond

# 重新加載

systemctl reload crond

2. 開(kāi)機(jī)自動(dòng)啟動(dòng)cron服務(wù)

systemctl start crond.service

3. 通過(guò)crontab命令管理定時(shí)任務(wù)

crontab命令用法如下:

Usage:

crontab [options] file

crontab [options]

crontab -n [hostname]

Options:

-u define user

-e edit user's crontab

-l list user's crontab

-r delete user's crontab

-i prompt before deleting

-n set host in cluster to run users' crontabs

-c get host in cluster to run users' crontabs

-s selinux context

-x enable debugging

4. 定時(shí)任務(wù)格式

查看/etc/crontab文件,里面有格式說(shuō)明:

# 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

# [分] [時(shí)] [日] [月] [周] [需要執(zhí)行的命令]

詳細(xì)的cron表達(dá)式可以查看這篇文章:

5. 添加一個(gè)定時(shí)任務(wù)

# 進(jìn)入編輯模式,按照格式添加,保存退出

# crontab會(huì)自動(dòng)檢查語(yǔ)法是否正確,如果錯(cuò)誤會(huì)有提示。

[root@localhost /]# crontab -e

*/1 * * * * /home/app/zipkin/zipkin-dependencies.sh

*/1 * * * *:表示每分鐘執(zhí)行一次

/home/app/zipkin/zipkin-dependencies.sh:是需要執(zhí)行的命令

添加成功后,查看定時(shí)任務(wù)列表:

[root@localhost /]# crontab -l

*/1 * * * * /home/app/zipkin/zipkin-dependencies.sh

6. 查看執(zhí)行日志

cat /var/log/cron

總結(jié)

以上是生活随笔為你收集整理的linux 7 定时任务设置,centos7 配置crontab定时任务的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。