crontab support

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
User avatar
Sciamano
Posts: 264
Joined: Sat Oct 15, 2016 12:18 pm
Location: Italy

crontab support

Post by Sciamano »

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
User avatar
Sciamano
Posts: 264
Joined: Sat Oct 15, 2016 12:18 pm
Location: Italy

Re: crontab support

Post by Sciamano »

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
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: crontab support

Post by Fourdee »

Sciamano wrote: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
You need to put cron jobs (they are basically bash scripts) in the following respective folders:

Code: Select all

/etc/cron.hourly
/etc/cron.daily
/etc/cron.monthly
Make sure to chmod +x your script

Example daily cron script (DietPi):

Code: Select all

nano /etc/cron.daily/dietpi
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
User avatar
Sciamano
Posts: 264
Joined: Sat Oct 15, 2016 12:18 pm
Location: Italy

Re: crontab support

Post by Sciamano »

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... :(
odreezy

Re: crontab support

Post by odreezy »

User avatar
Sciamano
Posts: 264
Joined: Sat Oct 15, 2016 12:18 pm
Location: Italy

Re: crontab support

Post by Sciamano »

Thanks. But I've found out that the latest version of DietPi apparently supports the systemwide cron file set with command 'crontab -e'
diggy_dude
Posts: 10
Joined: Sat Oct 01, 2016 4:41 pm

Re: crontab support

Post by diggy_dude »

How do you plan to make a cron task run every few seconds? The lowest frequency that crontab will run is once per minute.
User avatar
Sciamano
Posts: 264
Joined: Sat Oct 15, 2016 12:18 pm
Location: Italy

Re: crontab support

Post by Sciamano »

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

Re: crontab support

Post by were55 »

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

thanks
Kymru
Posts: 30
Joined: Wed Jan 25, 2017 6:40 pm

Re: crontab support

Post by Kymru »

were55 wrote: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?
Post Reply