mirror of
https://github.com/notwa/rc
synced 2025-02-05 07:43:22 -08:00
minutemaid
This commit is contained in:
parent
3623b43a69
commit
44af125b70
1 changed files with 23 additions and 0 deletions
23
sh/minutemaid
Executable file
23
sh/minutemaid
Executable file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/bin/zsh
|
||||||
|
# crontab usage:
|
||||||
|
# * * * * * ~/sh/minutemaid 9 do something # runs every nine minutes
|
||||||
|
local bottom=0 strip=0 interval=2 opt=
|
||||||
|
while getopts ':h' opt; do
|
||||||
|
case $opt in
|
||||||
|
?) local fd=0
|
||||||
|
[ $opt = h ] && fd=0 || fd=2
|
||||||
|
echo -E "usage: $0 {period} {command} [{args...}]" >&$fd
|
||||||
|
[ $opt = h ] && return 0 || return 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
|
local period=${1:?no period specified}
|
||||||
|
shift
|
||||||
|
local cmd=${1:?no command specified}
|
||||||
|
shift
|
||||||
|
|
||||||
|
sec="$(date +%s)"
|
||||||
|
let min=sec/60
|
||||||
|
let mod=min%period
|
||||||
|
[ $mod -eq 0 ] && "$cmd" "$@"
|
Loading…
Add table
Reference in a new issue