Here is a simple shell script to create cronjob, using the above code.
#!/bin/sh
sudo crontab -l > cron_bkp
sudo echo "0 10 * * * sudo /home/test.sh >/dev/null 2>&1" >> cron_bkp
sudo crontab cron_bkp
sudo rm cron_bkp
Please note, if you want to overwrite existing crontab with new one, just use > operator instead of >> above.
gefunden auf: https://fedingo.com/how-to-create-cron-job-using-shell-script/