Skip to content

Commit

Permalink
crontab installation checks if python is already executed
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekbielaszewski committed Aug 22, 2021
1 parent 1dfcfdf commit 0b10508
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions install.sh
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

0 comments on commit 0b10508

Please sign in to comment.