Source
bash arrays
myarray(1 2 3)
mytextarray("text1" "text2")
crontab
- special cron strings:
@reboot, @yearly/annually, @monthly, @weekly, @daily, @midnight, @hourly
sudo crontab -u root -e
# every day at 4am create compressed backup of home directory
0 4 * * * tar -cvzf /var/backups/home.$(date -I).tar.gz /home/
# every day at 4:30am remove all home dir backups older than 3 days
30 4 * * * find /var/backups -name "home.*.tar.gz" -mtime +3 -delete
Script to update docker containers
#!/bin/bash
dockerdir="/home/p10/docker"
for dir in $(ls $dockerdir); do
cd "$dockerdir/$dir"
docker compose pull && docker compose up -d
done
# every Sunday at 12am run dockerpull script
0 0 * * 7 /home/p10/.local/bin/dockerpull
journalctl
# list logs for a specific systemd unit
journalctl -u [unit]
# list logs since a particular time
journalctl --since "[time]"
at
# schedule a one-off command
at
# list pending at jobs
atq
# remove a pending at job
atrm
EOF