I have a deployment script and in it I'm trying to add a cron job. This is the code I am using which I found on stackoverflow. I'm running debian 8.
# ADD CRON
crontab -l > mycron
echo "10 * * * * cd /var/www/test/ && ./test" >> mycron
crontab mycron
rm mycron
When I run these commands I get the reply: no crontab for root
What am I doing wrong here, and how can I get it so I can add this cron job using a bash script? Thank you.