user dietpi/root crontab not working Topic is solved

Having issues with your DietPi installation, or, found a bug? Post it here.
User avatar
trendy
Posts: 126
Joined: Tue Feb 25, 2020 2:54 pm

user dietpi/root crontab not working

Post by trendy »

I added a few cronjobs in dietpi user crontab (with 'crontab -e')

Code: Select all

15 5 * * * /usr/bin/touch /mnt/backup/magiatiko/test-$(date +%F)
16 5 * * * /usr/bin/scp root@magiatiko:/tmp/backup-magiatiko-$(date +%F).tar.gz /mnt/backup/magiatiko/
20 5 * * * /usr/bin/find /mnt/backup/magiatiko -type f -mtime +30 -exec rm -f {} \;
21 5 * * * /usr/bin/find /mnt/backup/kodi -type f -mtime +30 -exec rm -f {} \;
I added the first one to verify that it indeed works, but no file is created.
All commands run successfully when run from shell as user dietpi.
Am I missing something?
Last edited by trendy on Tue Jul 21, 2020 1:59 pm, edited 1 time in total.
User avatar
Joulinar
Posts: 2091
Joined: Sat Nov 16, 2019 12:49 am

Re: user dietpi crontab not working

Post by Joulinar »

Did you tried to place inside root user crontab?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
trendy
Posts: 126
Joined: Tue Feb 25, 2020 2:54 pm

Re: user dietpi crontab not working

Post by trendy »

No, because I don't want to run the commands as root user.
Doesn't the dietpi user crontab work?
User avatar
Joulinar
Posts: 2091
Joined: Sat Nov 16, 2019 12:49 am

Re: user dietpi crontab not working

Post by Joulinar »

it was more for testing purposes to check if it's working at all
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
trendy
Posts: 126
Joined: Tue Feb 25, 2020 2:54 pm

Re: user dietpi crontab not working

Post by trendy »

It is not working for root either.
I added the first job (with touch) and it was not created.
User avatar
Joulinar
Posts: 2091
Joined: Sat Nov 16, 2019 12:49 am

Re: user dietpi/root crontab not working

Post by Joulinar »

ok I created a cron job for this night on one of my test RPi systems. let's see how it's going
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
Joulinar
Posts: 2091
Joined: Sat Nov 16, 2019 12:49 am

Re: user dietpi/root crontab not working

Post by Joulinar »

Hi @trendy

I did a test entry on my crontab for user dietpi

Code: Select all

dietpi@DietPi3:~$ crontab -l
00 00 * * * date > /tmp/date.log
dietpi@DietPi3:~$
And for me it was working fine. The file was created at Midnight as expected

Code: Select all

root@DietPi3:/tmp# ls -la |grep date.log
-rw-r--r--  1 dietpi dietpi   30 Jul 22 00:00 date.log
root@DietPi3:/tmp# cat date.log
Wed Jul 22 00:00:01 CEST 2020
root@DietPi3:/tmp#
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
trendy
Posts: 126
Joined: Tue Feb 25, 2020 2:54 pm

Re: user dietpi/root crontab not working

Post by trendy »

Your date command worked for me as well.
I think there is something wrong with the special characters in my commands, therefore let's mark it as solved. Thank you for the tip!
User avatar
Joulinar
Posts: 2091
Joined: Sat Nov 16, 2019 12:49 am

Re: user dietpi/root crontab not working

Post by Joulinar »

Just an idea. Place you commands into a script and let the script be executed by crontab.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
trendy
Posts: 126
Joined: Tue Feb 25, 2020 2:54 pm

Re: user dietpi/root crontab not working

Post by trendy »

I was trying to avoid that, not to have many different scripts. If I fail to escape the special characters correctly, I'll resort to that.
Post Reply