matthewh
Posts: 15
Joined: Tue Dec 30, 2014 5:04 pm

CRONTAB

Wed Dec 31, 2014 7:33 pm

I added this to /etc/crontab

*/5 * * * * root cd / && run-parts --report /etc/cron.fiveminute

Then restarted cron. Why won't any of my scripts in /etc/cronfiveminute run?

jamiesk
Posts: 95
Joined: Mon Nov 26, 2012 8:48 pm
Location: Ipswich, Suffolk, England, UK.

Re: CRONTAB

Fri Jan 02, 2015 3:14 pm

You might need to specify something else too. I have a script which run every 5 minutes between two hours...

*/5 9-16 * * * /home/pi/sma.cron

Have a go with the hours, even 0-23 and it might work for you.
Pi1 (Nov 2012 loft)= 1KW immersion controller for Solar panel
Pi2 (Jan 2013 living room)=Play thing
Pi3 (Feb 2013 mobile)= Play thing with Tandy Ladder board,breakout board,Nokia display
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=26&t=28193

User avatar
emgi
Posts: 357
Joined: Thu Nov 07, 2013 4:08 pm
Location: NL

Re: CRONTAB

Fri Jan 02, 2015 3:49 pm

I'm a bit unsure about the syntax of your ctrontab entry. :|
As far as my experience goes, they look like the one from the previous poster.
Special care must be taken to set all file paths correctly. To be safe, you should even consider to do this for system files.
At least things should be tested thoroughly and file paths are to be the first suspects when things are failing.
Always begin with running the script from the command line. Only put it in crontab when cli execution works.

One of the many explanations on the web: http://v1.corenominal.org/howto-setup-a-crontab-file/

/emgi

User avatar
DougieLawson
Posts: 35347
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: CRONTAB

Fri Jan 02, 2015 4:05 pm

A line like

Code: Select all

*/5 * * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.fiveminute )
should run every five minutes. Did you reload cron with /etc/init.d/cron reload after updating /etc/crontab? Are all of the scripts in /etc/cron.fiveminute owned by root and executable?
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

matthewh
Posts: 15
Joined: Tue Dec 30, 2014 5:04 pm

Re: CRONTAB

Fri Jan 02, 2015 5:49 pm

Here is default /etc/crontab on raspberry pi.

17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )

I simply created /etc/cron.fiveminute with sudo mkdir then added:

*/5 * * * * root cd / && run-parts --report /etc/cron.fiveminute

Pretty much copying the default cron.hourly

Then I rebooted.

ghans
Posts: 7863
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: CRONTAB

Fri Jan 02, 2015 5:49 pm

Another caveat : run-parts disallows scripts with "file extensions"
like .sh or .old or .bak (this is by design).


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

matthewh
Posts: 15
Joined: Tue Dec 30, 2014 5:04 pm

Re: CRONTAB

Fri Jan 02, 2015 5:54 pm

ghans wrote:Another caveat : run-parts disallows scripts with "file extensions"
like .sh or .old or .bak (this is by design).
ghans
That would be the issue. Why is this? Can I change it?

User avatar
DougieLawson
Posts: 35347
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: CRONTAB

Fri Jan 02, 2015 6:00 pm

run-parts --regex="^.*sh" --report /etc/cron.fiveminutes # run anything named *.sh
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

matthewh
Posts: 15
Joined: Tue Dec 30, 2014 5:04 pm

Re: CRONTAB

Tue Jan 13, 2015 10:53 pm

What is strange is I have a Centos 5.x server with exact same line in crontab using run-parts and it will execute anything in that directory regardless of extension or no extension.

ghans
Posts: 7863
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: CRONTAB

Wed Jan 14, 2015 7:36 am

It's Debian specific.

Code: Select all

man run-parts
has more info.


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Return to “Raspbian”