Linux命令---指定到具体时间

来源:互联网 发布:梦幻西游手游秒抢软件 编辑:程序博客网 时间:2024/05/17 06:05

sleep命令是一个延迟命令,可以实现延迟执行一些指令

通过man sleep 可以看到具体的说明:


NAME
sleep - delay for a specified amount of time

SYNOPSIS
sleep NUMBER[SUFFIX]…
sleep OPTION

DESCRIPTION
Pause for NUMBER seconds. SUFFIX may be ‘s’ for seconds (the default), ‘m’ for minutes, ‘h’ for hours or ‘d’ for days. Unlike most implementations that require NUMBER be an integer, here
NUMBER may be an arbitrary floating point number. Given two or more arguments, pause for the amount of time specified by the sum of their values.


可以看到,能够指定延迟的时间,sleep 数字+单位
延迟10秒 sleep 10s 或者 sleep 10

分钟:m
小时:h
天:d

那么貌似不能指定在具体的时间执行,例如凌晨3点执行,难道还让我自己去计算时间差不行?
当然还是有解决方法的。如下:

sleep $(($(date +%s -d '2016-11-26 03:00') - $(date +%s)))

结合date命令,能够延迟到指定具体指定的时间。不用自己再给个大约的时间了。

1 0
原创粉丝点击