Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Cron question
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Kurogane
n00b
n00b


Joined: 23 May 2010
Posts: 39

PostPosted: Wed Apr 11, 2018 8:06 pm    Post subject: Cron question Reply with quote

Hi,

I've a problem with install cronjob properly.

I'm using cronie as my scheduled tasks. I create a cronjob in /etc/cron.d but the job is not done. I restart the deamon i double check is the files is executable and it is so i'm not know why crontab no detect the files i create.

What i do wrong?
Back to top
View user's profile Send private message
Zucca
Veteran
Veteran


Joined: 14 Jun 2007
Posts: 1520
Location: KUUSANKOSKI, Finland

PostPosted: Wed Apr 11, 2018 10:24 pm    Post subject: Reply with quote

I'm not sure if I got this right, but I think you have the the files in wrong directory...

/etc/cron.d/ should contain "cron scheduler files" (I don't know proper name for those files) which are not meant to be executed. Instead those files contain configurations of what and when to execute.
Here's an example:
/etc/cron.d/sysstat:
# Run system activity accounting tool every 10 minutes
*/10 * * * * root /usr/lib64/sa/sa1 1 1
# 0 * * * * root /usr/lib64/sa/sa1 600 6 &
# Generate a text summary of previous day process accounting at 00:07
7 0 * * * root /usr/lib64/sa/sa2 -A


/etc/cron.daily/ for example should contain files with executable bit, which are then executed once a day in this case.

If you have right files in right directories, then run the crondaemon in verbose or debug mode and check the logs for errors.
_________________
..: Zucca :..

Code:
ERROR: '--failure' is not an option. Aborting...
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1656
Location: United Kingdom

PostPosted: Wed Apr 11, 2018 10:47 pm    Post subject: Re: Cron question Reply with quote

Kurogane wrote:
I create a cronjob in /etc/cron.d but the job is not done.

Just to be sure, how exactly are you creating a cronjob? Please would you give an example of the steps you are using to create the cronjob, and its contents.
_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Kurogane
n00b
n00b


Joined: 23 May 2010
Posts: 39

PostPosted: Thu Apr 12, 2018 7:32 am    Post subject: Re: Cron question Reply with quote

Fitzcarraldo wrote:
Kurogane wrote:
I create a cronjob in /etc/cron.d but the job is not done.

Just to be sure, how exactly are you creating a cronjob? Please would you give an example of the steps you are using to create the cronjob, and its contents.


I'm just create a simple cronjob

Here what is contain

Code:

*/2 * * * * /sbin/sa-update


Even if i put a simple echo

Code:

*/1 * * * * echo "test" > /root/test


Logs says nothing no errors.
Back to top
View user's profile Send private message
Zucca
Veteran
Veteran


Joined: 14 Jun 2007
Posts: 1520
Location: KUUSANKOSKI, Finland

PostPosted: Thu Apr 12, 2018 8:05 am    Post subject: Re: Cron question Reply with quote

Kurogane wrote:
Code:

*/1 * * * * echo "test" > /root/test


Logs says nothing no errors.
Try with
Code:
*/1 * * * * sh -c 'echo "test" > /root/test'
... instead.

Also check your cron daemon configs. Try to set message output to verbose and redirect to syslog if possible.
_________________
..: Zucca :..

Code:
ERROR: '--failure' is not an option. Aborting...
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1656
Location: United Kingdom

PostPosted: Thu Apr 12, 2018 11:36 am    Post subject: Reply with quote

Kurogane,

Just to be sure, are you creating the cron job from your user account, or from the root user's account?

Code:
fitzcarraldo@clevow230ss ~ $ crontab -e

Code:
clevow230ss fitzcarraldo # crontab -e

_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Zucca
Veteran
Veteran


Joined: 14 Jun 2007
Posts: 1520
Location: KUUSANKOSKI, Finland

PostPosted: Thu Apr 12, 2018 12:08 pm    Post subject: Reply with quote

@Fitzcarraldo: Correct me if I'm wrong, but AFAIK files under /etc/cron.d/ are to be edited manually (or placed there by packages during install phase), without using the crontab command.
_________________
..: Zucca :..

Code:
ERROR: '--failure' is not an option. Aborting...
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1656
Location: United Kingdom

PostPosted: Thu Apr 12, 2018 1:05 pm    Post subject: Reply with quote

Zucca,

My mistake, they can be edited directly; no need to use 'crontab -e'.

However, from crontab(5):

crontab(5) wrote:
Jobs in /etc/cron.d/

The jobs in cron.d and /etc/crontab are system jobs, which are used
usually for more than one user, thus, additionally the username is
needed
. MAILTO on the first line is optional.

EXAMPLE OF A JOB IN /etc/cron.d/job

#login as root
#create job with preferred editor (e.g. vim)
MAILTO=root
* * * * * root touch /tmp/file

Perhaps Kurogane could try adding the username as shown in the example from man crontab.5.

Code:
*/1 * * * * root 'echo "test" > /root/test'

_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Zucca
Veteran
Veteran


Joined: 14 Jun 2007
Posts: 1520
Location: KUUSANKOSKI, Finland

PostPosted: Thu Apr 12, 2018 1:41 pm    Post subject: Reply with quote

D'oh! I totally forgot the username requirement. I even pasted my own example, but didn't saw it missing in OP's code. :P
_________________
..: Zucca :..

Code:
ERROR: '--failure' is not an option. Aborting...
Back to top
View user's profile Send private message
Kurogane
n00b
n00b


Joined: 23 May 2010
Posts: 39

PostPosted: Thu Apr 12, 2018 7:32 pm    Post subject: Reply with quote

Yes, i'm using directly under folder /etc/cron.d/

Seems now is working adding the username. But why? i understand system users need to specify but root?
Back to top
View user's profile Send private message
Zucca
Veteran
Veteran


Joined: 14 Jun 2007
Posts: 1520
Location: KUUSANKOSKI, Finland

PostPosted: Thu Apr 12, 2018 8:18 pm    Post subject: Reply with quote

The username there is to set priviliges of the process ran by cron.
If you leave it out then cron thinks your "zeroth" argument (the name of the command) is the username.
In your case crond tried to run an empty/null command with "/sbin/sa-update" as username. Which obviously failed.
As to why didn't the cron daemon spat out any error messages to syslog... I don't know. Did you check the crond settings?
_________________
..: Zucca :..

Code:
ERROR: '--failure' is not an option. Aborting...


Last edited by Zucca on Fri Apr 13, 2018 7:20 am; edited 1 time in total
Back to top
View user's profile Send private message
Kurogane
n00b
n00b


Joined: 23 May 2010
Posts: 39

PostPosted: Thu Apr 12, 2018 8:58 pm    Post subject: Reply with quote

No, only this

Code:
Apr 12 14:49:01 [crond] (*system*) RELOAD (/etc/cron.d/sa)


Which contains

Code:
*/2 * * * * /sbin/sa-update


Thats all.
Back to top
View user's profile Send private message
Zucca
Veteran
Veteran


Joined: 14 Jun 2007
Posts: 1520
Location: KUUSANKOSKI, Finland

PostPosted: Fri Apr 13, 2018 7:23 am    Post subject: Reply with quote

Then I'd say it's a bug in cronie if it doesn't inform you in anyway if you have supplied an invalid crontab. :\
_________________
..: Zucca :..

Code:
ERROR: '--failure' is not an option. Aborting...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum