-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crontab installation checks if python is already executed
- Loading branch information
1 parent
1dfcfdf
commit 0b10508
Showing
1 changed file
with
13 additions
and
3 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
#!/bin/bash | ||
export backup_date=`date +20%y%m%d-%H%M%S` | ||
crontab -l > cron.backup.${backup_date} | ||
crontab < ./crontab.txt | ||
|
||
SERVICE="python" | ||
|
||
if pgrep -x "$SERVICE" >/dev/null | ||
then | ||
echo "$SERVICE is running. I won't replace th crontab right now. Kill python processes first!" | ||
else | ||
export backup_date=`date +20%y%m%d-%H%M%S` | ||
echo 'Backing up old crontab into $backup_date' | ||
crontab -l > cron.backup.${backup_date} | ||
echo "Installing new crontab" | ||
crontab < ./crontab.txt | ||
fi |