-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In this release, I worked on the script to take notification minutes,…
… hours, and weekdays.
- Loading branch information
1 parent
d4f32a3
commit c65a0a6
Showing
5 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Thu Jun 6 10:50:01 PKT 2024: It's time! Running the desired command. | ||
Thu Jun 6 10:51:01 PKT 2024: It's time! Running the desired command. | ||
Thu Jun 6 10:52:01 PKT 2024: It's time! Running the desired command. | ||
Thu Jun 6 10:53:01 PKT 2024: It's time! Running the desired command. | ||
Thu Jun 6 10:54:01 PKT 2024: It's time! Running the desired 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
|
||
# Desired time in HH:MM format | ||
DESIRED_TIME="10:52" | ||
|
||
DESIRED_WEEKDAY="friday" | ||
|
||
# Log file location | ||
LOG_FILE="/mnt/d/go/src/github.com/ibilalkayy/flow/logfile.log" | ||
|
||
# Function to install and configure NTP | ||
install_and_sync_ntp() { | ||
# Check if NTP is installed | ||
if ! command -v ntpd &> /dev/null; then | ||
echo "$(date): NTP not found. Installing NTP..." >> "$LOG_FILE" | ||
|
||
# Install NTP based on the package manager available | ||
if command -v apt-get &> /dev/null; then | ||
sudo apt-get update && sudo apt-get install -y ntp | ||
elif command -v yum &> /dev/null; then | ||
sudo yum install -y ntp | ||
elif command -v dnf &> /dev/null; then | ||
sudo dnf install -y ntp | ||
else | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Start and enable NTP service | ||
if command -v systemctl &> /dev/null; then | ||
sudo systemctl start ntpd | ||
sudo systemctl enable ntpd | ||
elif command -v service &> /dev/null; then | ||
sudo service ntp start | ||
sudo update-rc.d ntp defaults | ||
fi | ||
|
||
# Force synchronize the clock immediately | ||
if command -v ntpd &> /dev/null; then | ||
sudo ntpd -gq | ||
elif command -v ntpdate &> /dev/null; then | ||
sudo ntpdate pool.ntp.org | ||
fi | ||
} | ||
|
||
# Install and synchronize NTP | ||
install_and_sync_ntp | ||
|
||
# Get the current time in HH:MM format | ||
CURRENT_TIME=$(date +"%H:%M") | ||
|
||
CURRENT_WEEKDAY=$(date +"%A") | ||
|
||
# Check if the current time matches the desired time | ||
DESIRED_WEEKDAY="friday" | ||
# Run your command and log the output | ||
echo "$(date): It's time! Running the desired command." >> "$LOG_FILE" | ||
fi |
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