Skip to content

Instantly share code, notes, and snippets.

@litefeel
Created May 18, 2015 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save litefeel/77e973d62e29e955cad9 to your computer and use it in GitHub Desktop.
Save litefeel/77e973d62e29e955cad9 to your computer and use it in GitHub Desktop.
shell 脚本 添加cron
#!/bin/bash
# put old cron to file
crontab -l > tmpcron.txt
s=`crontab -l | grep '/root/dropbox.py start'`
# echo "$s"x
if [[ -z "$s" ]]; then
echo "00 04 * * * /root/dropbox.py start" >> tmpcron.txt
fi
s=`crontab -l | grep '/root/dropbox.py stop'`
# echo "$s"x
if [[ -z "$s" ]]; then
echo "10 04 * * * /root/dropbox.py stop" >> tmpcron.txt
fi
#install new cron file
crontab tmpcron.txt
rm -f tmpcron.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment