在bash中测试当前时间?
如何测试当前小时是否等于shell中的给定小时?在bash中测试当前时间?,bash,shell,date,Bash,Shell,Date,如何测试当前小时是否等于shell中的给定小时? 小时应为24小时格式 如何实现这一点 While true: do current_hour = ... if current_hour == 21: python aaa.py done 是否可以使用at调度python程序?如果您想在21:00运行一次,请输入crontab。或者您的意思是,正如所写的,您希望在21:00-21:59之间尽可能多地运行Python? while true;
小时应为24小时格式 如何实现这一点
While true:
do
current_hour = ...
if current_hour == 21:
python aaa.py
done
是否可以使用
at
调度python程序?如果您想在21:00运行一次,请输入crontab
。或者您的意思是,正如所写的,您希望在21:00-21:59之间尽可能多地运行Python?
while true; do
hour=$(date +%H)
if [ $hour == 21 ] ; then
python aaa.py
fi
# now sleep until next hour
sleep $(((60 - $(date +%M))*60))
done