command="$my_path/myscript.sh" > /dev/null 2>&1" job="* /5 * * * * $command" cat <(grep -i -v "$command" <(crontab -l)) <(echo "$job") | crontab -
Note that this is for BASH, not SH, since the syntax with the brackets is only available in BASH. As you can see, the last line is the critical one. In the first brackets using the grep tool, we catch everything currently in the crontab “except our command”, so this will prevent from adding the $command even if it is already in crontab. After that, we echo our job to the end of the current jobs, and redirect it to cat as a standart input. Since the standart output of cat will be the whole crontab list “with our new job”, we can use crontab with its “-” option to get the arguments from the stadart output. Hope this helps.