非特定时间每天一次crontab?

2024-10-05 12:25:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个python脚本,我希望每天只运行一次。 我对crontab命令做了一些研究,它似乎是这样做的,但是在每天固定的时间。 问题是,我的电脑不会整天开机,也不可能有一个具体的时间来运行它。我能做什么?在

日志文件能帮上忙吗?我想每5分钟左右做一次crontab,然后扫描一个日志文件,看看一天中有没有运行。在


Tags: 文件命令脚本时间电脑crontab开机
3条回答

安装^{},这是一个cron调度器,当您的计算机开机时,它将处理每天最多运行一次的任务。在

从维基百科页面:

anacron is a computer program that performs periodic command scheduling which is traditionally done by cron, but without assuming that the system is running continuously. Thus, it can be used to control the execution of daily, weekly, and monthly jobs (or anything with a period of n days) on systems that don't run 24 hours a day.

@reboot可在crontab条目中使用,以便在系统重新启动时运行一次脚本。在

例如

[test@host1 ~]$crontab -l    
@reboot     /home/test/bootScript.sh

Anacron will do it

或者

at

阿纳克龙可能是你最好的选择。在

相关问题 更多 >

    热门问题