开发者

Auto set cron bash script?

How to make some script to auto set it's execution based on 开发者_如何转开发some time it gets from database or some other way?

Any simple, plain example for that?


Assumptions:

  • you have a script what selecting the execution date and the command from the database
  • the output format from this script is: [[CC]YY]MMDDhhmm <space> command_name and_args

For example this will read pairs of "date" "command" from the standard input:

while read exectime command
do
    echo "$command" | at -t "$exectime"
done

Use it like:

/path/to/script_select_from_database | ./the_above_script

or this one

exectime="$1"
shift
echo "$@" | at -t "$exectime"

invoke it"

./this_script `/path/to/script_select_from_database`

combine both to one script, and/or any other variation...

The scripts queue your commands for the execution with the at command. see man at.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜