Last active
May 21, 2017 22:27
-
-
Save gwpl/e1d7dc9f9ce1684ff153f36ff45fc440 to your computer and use it in GitHub Desktop.
Handy snippet to depending behaviour on hour in bash
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
echo 'Current hour' | |
hour=$(date +%H); | |
if [ $hour -gt 9 -a $hour -lt 23 ]; then echo -n '*'; else echo -n '#'; fi; echo ' '$hour; | |
echo 'Test around the clock:' | |
for hour in {0..23} {0..23}; do | |
if [ $hour -gt 9 -a $hour -lt 23 ]; then echo -n '*'; else echo -n '#'; fi; echo ' '$hour; | |
done | |
echo 'If you need to depend on UTC, just add `-u` flag to `date` command' |
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
# Example of depend_on_hour modification, that pauses and resumes bitcoind on given times. | |
# Purpose? Quieter disks at night :) | |
# Set this script with cron or systemd-timers | |
echo 'Current hour' | |
hour=$(date +%H); | |
if [ $hour -gt 9 -a $hour -lt 23 ]; then | |
set -x | |
killall -v -CONT bitcoind | |
else | |
set -x | |
killall -v -STOP bitcoind | |
fi; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This may be also helpful:
pgrep -f 'rsync./path.' -a # to investigate
pkill -CONT -f "rsync./path." # and to catch -CONT or -STOP