This is the paragraph that’s missing from the introduction of remind’s man page, and every article I’ve ever read about it.
If there are timed reminders for later in the day, then remind will continue running in the background, sending timed reminders to the terminal at their appointed times. So you could be editing a file in vi and suddenly “Dentist appointment” appears on the screen. This is in addition to triggering all timed reminders scheduled for the current day when first run.
I wasn’t expecting this.
Although running in the background like this is very similar to running as a daemon, this is not the daemon mode referred to in the man page.
So what’s different about “daemon” mode?
Daemon mode (-z[n]
)is described in the man page. This is where remind runs in the foreground (not what you’d expect, right?) but now it checks the reminder file(s) every n minutes (default, 1).
This file-checking feature is nice, because it means you can edit your reminder files anytime you want and you don’t have to worry about stopping and re-starting a remind process. (I originally thought I’d have to do this with incron)
Much later in the man page…
After the man page describes the -z argument, if you continue reading, you will eventually find a section that describes daemon mode in more detail.
Surprise, surprise, no normal reminders are issued when in daemon mode; only timed reminders.
So that RUN
command that was supposed to run today is going to be ignored if remind is running in daemon mode.
Who would have guessed?
Daemon mode is only good for timed reminders. It’s probably best used when you’re running a graphical desktop and you want those timed reminders to pop up using xmessage or something.
This is done with the
-k
option as in:remind -z '-kxmessage %s &'
You’ll probably want a cron job to handle any RUN ONCE commands
If you’re like me, then you use remind run commands on certain hard-to-calculate dates that remind handles well.
In my case, I use remind to add tasks to Task Warrior to take out the trash cans. The trash gets picked up on different days if there was a holiday that week; exactly the sort of scheduling that remind excels at.
And, of course, you use i3wm or something similar as your usual desktop, so you want to use the -z
and -k
options to have reminders pop up in xmessage or gmessage.
This means that your regular reminders are going to be ignored unless you run remind in a non-daemon mode as well.
The -q
option, causes remind do do just about the opposite of daemon mode; it causes it to not hang around waiting for timed reminders. Or, in the words of the man page, “not queue timed reminders for later execution”. Essentially, -q
causes remind to run, and then quit without sticking around in the background (as usual), or foreground (as in daemon mode), waiting to post timed reminders on the screen.
The -a
option does something similar. It causes remind to “not immediately trigger timed reminders that trigger on the current day. Not knowing that this is remind’s default behavior could lead to problems. I’m not sure why anyone would expect that the default behaviour is to immediately trigger any events set to trigger later today, that is indeed, the default. Weird, huh?
By combining -a
and -q
, we eliminate all timed reminders, only process ‘normal’ (untimed) reminders for the current day, and then quit; perfect for those RUN ONCE
commands. Here’s an example crontab line that will run rem at 4 AM, sending standard output to /dev/null:
0 4 * * * rem -a -q >/dev/null
As far as I know, there’s no option to just run the RUN ONCE
commands, but piping the text output to /dev/null accomplishes about the same thing.
However, if this cron job is the only way the RUN commands are getting processed, and you’re running this only once a day, you might throw in the -o
option to ignore the ONCE directive just for good measure. The ONCE commands shouldn’t be getting processed any other way, but just in case something goes wrong and remind thinks it’s already processed those ONCE commands, you’ll be all set. If I remember correctly, remind checks the access date on the main remind file to try to figure out if its run the ONCE commands already. I seem to remember this not being a fool-proof system.
0 4 * * * rem -a -q -o >/dev/null
But what about getting a day’s overview
Originally, I thought that remind would (by default) just give you a list of things scheduled for today, and only wait in the background spitting out timed reminders when explicitly run in daemon mode. This is, as I’ve shown, not the case.
Getting that overview of things due today is very useful, and remind can do this, if you use the right flags.
For a nice compact view, I use: rem -n -q -b1|grep (date +%Y/%m/%d)|sort|cut -f 2- -d' '
This spits out a list things scheduled for today, with the timed items sorted by time at the top of the list. I use the fish shell, so I just save this command as a function called, ‘today’, but saving this function as a shell script is another option.
How about a morning pop-up?
You can cron the above command and pipe it to gmessage for a nice morning popup (xmessage works too, but I like gmessage better).
0 8 * * * rem -n -q -b1|grep $(date +\%Y/\%m\%d)|sort|cut -f 2- -d' '|gmessage -file - -title "Events" -timeout 43200
The above is a crontab entrance to send a popup at 8 AM every morning. The message will stay there for 12 hours (43200 seconds) if I don’t close it manually.