Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of automatically adding crontab to script

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains the "script automatically add crontab writing method", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "script automatically add crontab writing method" bar!

The code is as follows:

#! / bin/sh

BASEDIR= `dirname $0` /..

BASEDIR= `(cd "$BASEDIR"; pwd)`

PROGRAM=$BASEDIR/bin/daemon.sh

CRONTAB_CMD= "* / 1 * sh $PROGRAM once > / dev/null 2 > & 1 &"

(crontab-l 2 > / dev/null | grep-Fv $PROGRAM; echo "$CRONTAB_CMD") | crontab-

COUNT= `crontab-l | grep $PROGRAM | grep-v "grep" | wc-l `

If [$COUNT-lt 1]; then

Echo "fail to add crontab $PROGRAM"

Exit 1

Fi

Thank you for reading, the above is the "script automatically add crontab writing method" of the content, after the study of this article, I believe you automatically add the script to add crontab writing method of this problem has a deeper understanding, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report