Created
April 21, 2021 15:01
-
-
Save dalin-/d61f19705dfa088d0fe9ba5ca11da03a to your computer and use it in GitHub Desktop.
Cron Job to shutdown Docker+Lando nightly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Crontab entry to shut down Lando/Docker. | |
0 4 * * * /path/to/file/below/docker-shutdown.sh > /dev/null 2>&1 | |
# Here’s the script: | |
#!/bin/bash | |
# docker-shutdown | |
# Shutdown Lando, then Docker. | |
docker_running=`ps -fU $USER | grep -i "com.docker.hyperkit" | grep -v "grep"` | |
if [ -n "$docker_running" ]; then | |
echo 'shutting down Lando' | |
/usr/local/bin/lando poweroff | |
echo 'shutting down Docker' | |
killall Docker | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment