Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Check if my cronJob already exist
- Put my cronJob if it does not already exist
- or
- update my cronjob if one of the parameter of the command is different
- if [[ $(crontab -l | egrep -v "^(#|$)" | grep -q 'something'; echo $?) == 1 ]]
- then
- echo $(crontab -l ; echo '* 1 * * * something') | crontab -
- fi
- echo "* 1 * * * something" | crontab -
- echo "* 1 * * * something" | ssh user@host "crontab -"
- # on the machine itself
- echo "$(echo '* 1 * * * something' ; crontab -l)" | crontab -
- # via ssh
- echo "$(echo '* 1 * * * something' ; ssh user@host crontab -l)" | ssh user@host "crontab -"
- echo '0 0 * * 0 webadmin /usr/local/bin/tidy_logfiles' > ~/webadmin.cron
- scp -p ~/webadmin.cron root@remote_host:/etc/cron.d/webadmin
- ssh -q root@remote_host rm -f /etc/cron.d/webadmin
- unset VISUAL
- EDITOR='update_crontab () {
- set -e
- new=$(mktemp)
- if <"$1" grep -v "^#" | grep -w do_stuff; then
- # Remove existing entries containing do_stuff
- grep -v -w do_stuff "$1" >"$new"
- else
- cp "$1" "$new"
- fi
- # Add the new entry
- echo "1 2 3 4 5 do_stuff --new-options" >>"$new"
- mv "$new" "$1"
- }
- update_crontab' crontab -e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement