Bash的日期/时间算术 [英] Bash date/time arithmetic

查看:128
本文介绍了Bash的日期/时间算术的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一点击脚本分钟的一个给定的次数后挂起计算机。不过,我想扩展它告诉我的时候会是什么时候会被暂停,这样我就可以得到我已经离开了多久时间可以这么说一个大概的了解。

I have a little Bash script which suspends the computer after a given number of minutes. However, I'd like to extend it to tell me what the time will be when it will be suspended, so I can get a rough idea of how long time I have left so to speak.

#!/bin/sh
let SECS=$1*60
echo "Sleeping for" $1 "minutes, which is" $SECS "seconds."
sleep $SECS &&
pm-suspend

给脚本的唯一参数将是多少分钟,从现在的电脑应暂停。所有我想要添加到这个脚本基本上是一个回声例如说睡到HH:NN:SS。任何想法?

The only argument to the script will be how many minutes from now the computer should be suspended. All I want to add to this script is basically an echo saying e.g. "Sleeping until HH:nn:ss!". Any ideas?

推荐答案

发现了如何。

echo "The computer will be suspended at" $(date --date "now $1 minutes")

这篇关于Bash的日期/时间算术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆