cronjob_editor () { # usage: cronjob_editor '' '' if [[ -z "$1" ]] ;then printf " no interval specified\n" ;fi if [[ -z "$2" ]] ;then printf " no command specified\n" ;fi if [[ -z "$3" ]] ;then printf " no action specified\n" ;fi if [[ "$3" == add ]] ;then # add cronjob, no duplication: ( crontab -l | grep -v -F -w "$2" ; echo "$1 $2" ) | crontab - elif [[ "$3" == remove ]] ;then # remove cronjob: ( crontab -l | grep -v -F -w "$2" ) | crontab - fi } cronjob_editor "$1" "$2" "$3"