What is the preferred way to insert an entry in / etc / crontab if it does not exist, preferably using a single line?
Here is my sample entry that I want to place in / etc / crontab if it does not already exist there.
*/1 * * * * some_user python /mount/share/script.py
I am on CentOS 6.6, and so far I have this:
if grep "*/1 * * * * some_user python /mount/share/script.py" /etc/crontab; then echo "Entry already in crontab"; else echo "*/1 * * * * some_user python /mount/share/script.py" >> /etc/crontab; fi
source
share