crontab support

Hello, me again. Sorry for flooding the board, but I can’t seem to find the answer to this problem, and I guess it might be useful to others too.

Can cron jobs be added without using dietpi-cron?
The options there are a little limited, and since I need to run a script every 5 minutes, this can’t be done using dietpi-cron.

I tried with ‘crontab -e’ as I’m used to do this with Linux Mint. Would it work?
Of course it says there is no crontab for root so it opens an empty one.

So, basically, my question is: can cron jobs be set outside dietpi-cron and its limitations? And if so, would ‘crontab -e’ work for this or should the approach to be taken be different?

Thanks

Since I haven’t received any replies, I tried setting up a few cron commands after giving the ‘crontab -e’ command, and I can now desume that this is not working.

Any suggestions to overcome this limitation? I need to run a script every few seconds…
Thanks

You need to put cron jobs (they are basically bash scripts) in the following respective folders:

/etc/cron.hourly
/etc/cron.daily
/etc/cron.monthly

Make sure to chmod +x your script

Example daily cron script (DietPi):

nano /etc/cron.daily/dietpi

Yes, I know about this solution, but as I said before, I need to run a script every few seconds, therefore putting the script in the /etc/cron.hourly directory wouldn’t make it run with the needed frequency… :frowning:

This may be helpful:
http://serverfault.com/questions/449651/why-is-my-crontab-not-working-and-how-can-i-troubleshoot-it

Thanks. But I’ve found out that the latest version of DietPi apparently supports the systemwide cron file set with command ‘crontab -e’

How do you plan to make a cron task run every few seconds? The lowest frequency that crontab will run is once per minute.

Well, once per minute is still fine.
Waaaay better than once per hour…

Hello, I’m trying to use “crontab -e” but doesn’t run, any news regarding this will be activated in latest releases?

thanks

what are you putting into cron and what editor are you using?

have you done crontab -l to check your cron?

Hi Kymru,

I’m putting some lines to delete files and update xml graber, this is a crontab -l (deleted fist lines):

2 09,21 * * * /usr/bin/find /home/download/TV -mtime +2 -print0|xargs -0 /bin/rm -rf >> /home/tmp/delete_files.log 2>&1
5 14,21 * * * /usr/bin/find /home/download/movies -mtime +2 -print0|xargs -0 /bin/rm -rf >> /home/tmp/delete_files.log 2>&1

8 09,21 * * * /usr/bin/find /root/.config/deluge/state/*.torrent -mtime +2 -print0|xargs -0 /bin/rm -rf >> /tmp/delete_files.log 2>&1

@reboot /usr/bin/startweaved.sh

01 1,5,9,13,17,21 * * * /root/wg++/update.sh

(/home/tmp/ exist, but delete_files.log is 0 size.)

if I run any of this lines manually, they are executed without problems, also cron job is running:

root@DietPi:~/wg++# ps -ef|grep cron
root 941 1 0 11:55 ? 00:00:00 /usr/sbin/cron -f
root 4085 3327 0 12:05 pts/0 00:00:00 grep cron

Thanks

_2 9,21 * * * /usr/bin/find /home/download/TV -mmin +2 -print0 | xargs -0 /bin/rm -rf >> /home/tmp/delete_files.log 2>&1
5 14,21 * * * /usr/bin/find /home/download/movies -mmin +2 -print0 | xargs -0 /bin/rm -rf >> /home/tmp/delete_files.log 2>&1

8 9,21 * * * /usr/bin/find /root/.config/deluge/state/*.torrent -mmin +2 -print0 | xargs -0 /bin/rm -rf >> /tmp/delete_files.log 2>&1

@reboot /usr/bin/startweaved.sh

1 1,5,9,13,17,21 * * * /root/wg++/update.sh_

-mtime +2 is for 2 days and older yet you are running the cron daily
9.02am and 9.02pm
2.05pm and 9.05pm
9.08am and 9.08pm

-mmin is used for minutes

you can also drop the 0 from 2 09,21 and 8 09,21 and 01 1,5,9…

Hi Kymru,

first at all, thanks for your help, really appreciate it. I know I’m running the script to review the files older than 2 days, this is not the problem. The crontab is not running, even the other line “01 1,5,9,13,17,21 * * * /root/wg++/update.sh” (execute script every 4 hours), I can restart the process but is the same, not sure if I can review some log.

thanks

UPDATE
I re-write the cron file and now is working, maybe some character was there. Thanks for your help :wink: