How to add cron job in /etc/crontab

Hi,
How to add a cron job in /etc/crontab using a shell script.??:confused:
Actually the requirement is we need to run a script say, XXX.sh every 10 min through �cron�.
That can be achieved by adding the below code line in the /etc/crontab , (i.e., �crontab -e � command to add this to the crontab in a particular server.)
"0-59/10 * * * * XXX.sh"
But when I changed the server, I need to add the same code line in the crontab of that particular server.
So instead of doing the same many times, when I run a particular script in that particular server, that line should be added in the crontab of that particular server.:wall:
Thanks in advance.

#
# write the current crontab to a file.
#
crontab -l > crontab.txt

#
# append the new command to the file.
#
echo "new command" >> crontab.txt

#
# replace the current crontab with the new one.
#
crontab crontab.txt
1 Like

Thank you jsmithstl.... Its working for me now...

Or you can execute
crontab -e to edit directly the cronjobs.

Thanks for ur reply @dagio. But I actually need that to be done through the shell script.
I got it almost.