简体   繁体   English

我怎样才能在linux中创建非对称的cron作业?

[英]How can i make asymmetric cron job in linux?

I want to make asymmetric scheduled cron job. 我想制作非对称的预定cron作业。

My cPanel allows to make it like "x times for per min/hour/day/month" etc.. 我的cPanel允许使其像“每分钟/每小时/每天/每月的x倍”等。

But i want to make one cron job for different hours for everyday (everyday at 20.00, 20.04, 21.12, 03.00 etc). 但是我想每天为不同时间做一个cron工作(每天20.00,20.04,21.12,03.00等)。

Is this possible? 这可能吗?

You can specify a set of hours and minutes 您可以指定一组小时和分钟

4,12,0 20,21,03 * * * *

which will match 20:00, 20:04, 20:12, 21:00, 21:04, 21:12, 03:00, 03:04, 03:12 这将匹配20:00,20:04,20:12,21:00,21:04,21:12,03:00,03:04,03:12

If you want to be more specific than that, you would have to use separate entries, as Wiseguy pointed out. 如果你想要更具体,你必须使用单独的条目,如Wiseguy指出的那样。

Not directly. 不是直接的。

I don't know what abilities cPanel give you, keep in mind that you can create a cron entry several times, for different purposes Here's the cron entries that executes the script at different times. 我不知道cPanel给你的能力,请记住你可以多次创建一个cron条目,用于不同的目的这是在不同时间执行脚本的cron条目。

#execute myjob at 20:00,20:04 every day.
0,4 20 * * *  /path/to/myjob

#execute myjob at 20:30,20:46,21:30,21:46, 22:30,22:46  every day.
30,46 20,21,22 * * *  /path/to/myjob

#execute myjob at 21:12 on Monday ,Tuesday and Wednesday
21 12 * * 1-3  /path/to/myjob

#execute myjob 15 minutes past every 3. hour on Saturday
15 */3 * * 6  /path/to/myjob

Read more in the crontab manual 阅读crontab手册中的更多内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM