Joined February 2022
·

Corey Minter

SW/HW
·

Posted to Scheduling jobs in UNIX without cron over 1 year ago

Thanks for sharing. I adapted your technique to separate the scheduling from the task. For example, save the following as scheduled

#!/bin/bash
# run script at scheduled time
# (derived from script by Janos Gyerik
#  https://coderwall.com/p/eilosa/scheduling-jobs-in-unix-without-cron)
#
# usage:  scheduled <when> <script> [args...]
# e.g. scheduled '7:15' script arg1 arg2
#      scheduled 'now + 5 minutes' script arg1 arg2
# also note script will execute in $PWD
[[ $0 = /* ]] && script=$0 || script=$PWD/$0
when="$1"
shift
echo "$script '$when' $*" | at "$when" &>/dev/null
$* &>/dev/null

Then use with: scheduled 'now + 10 minutes' another_script arg1 arg2 arg3

Achievements
1 Karma
0 Total ProTip Views