Published at
Updated at
Reading time
2min
This post is part of my Today I learned series in which I share all my web development learnings.

While browsing a collection of shell one-liners, I found out about a command that I haven't seen before: leave.

The command is straightforward. Run it and define an absolute or relative time, and your terminal will remind you to leave it alone and go at a certain time.

# set the alarm for 2:10pm
$ leave 1410
Alarm set for Fri Nov 20 14:10:00 CET 2020. (pid 3121)

# set the alarm in two minutes
$ leave +2

# set the alarm in two minutes interactively
$ leave
When do you have to leave? +2
Alarm set for Fri Nov 20 09:05:21 CET 2020. (pid 50717)

When the time arrives, the command running in the background sends shell notifications and prints new lines telling you to go. And let me tell you the best part: it doesn't do that once; it does that repeatedly every minute after the set alarm time. It will try hard to make you leave!

Example showing the leave command in action

You can only stop the running leave process from annoying you by logging out of your shell session (or manually stopping the process). ๐Ÿ˜†

I love that! Maybe I should define leave 1900 in my .zshrc to force me to stop doing nerdy things late at night.

Edited: For the adventurous folks โ€“ Frederic Hemberger pointed out that you could also just shut down the system at a specific time using sudo shutdown -h 12:00 "Feierabend!". But be careful with this command; it could lead to data loss. ๐Ÿ˜†

If you're interested in reading comments and alternatives to the leave command, this post was trending on Hacker News.

If you enjoyed this article...

Join 5.4k readers and learn something new every week with Web Weekly.

Web Weekly โ€” Your friendly Web Dev newsletter
Reply to this post and share your thoughts via good old email.
Stefan standing in the park in front of a green background

About Stefan Judis

Frontend nerd with over ten years of experience, freelance dev, "Today I Learned" blogger, conference speaker, and Open Source maintainer.

Related Topics

Related Articles