nextday, nextweekday: Tomorrow or Next Weekday

nextday Before my UNIX systems had personal crontabs (), I wanted a way to make an at job () repeat itself the next weekday (skipping Saturday and Sunday) or, sometimes, every day. Our at was simple-minded and didn't understand dates like now + 1 day. This script with two names, nextday and nextweekday, did the job. I called it from inside my at job, like this:
 `...` 
% cat atjob somecommand sleep 60 at 2325 `nextweekday` < atjob

On Thursday, the result will be a command like at 2325 Friday atjob. On Friday, the command will be at 2325 Monday atjob; using nextday instead, the result would be at 2325 Saturday atjob.

The -n option returns a numeric weekday.

NOTE: This script only works with some versions of date. If your version doesn't understand format strings like +%format, install the date () from the tutorial.

You can install this script from the tutorial or from the online archive (). If you get it from the archive, ask tar to install nextday and its other link:

% tar xvf archive.tar nextday nextweekday x nextday, 1564 bytes, 4 tape blocks nextweekday linked to nextday

The script tests the name it was called with, in $0, to decide which command to run.

- JP