View previous topic :: View next topic |
Author |
Message |
Kurogane n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 23 May 2010 Posts: 52
|
Posted: Wed Apr 11, 2018 8:06 pm Post subject: Cron question |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Zucca Moderator
![Moderator Moderator](/images/ranks/rank-mod.gif)
![](images/avatars/8484577066727ff6a19116.gif)
Joined: 14 Jun 2007 Posts: 3939 Location: Rasi, Finland
|
Posted: Wed Apr 11, 2018 10:24 pm Post subject: |
|
|
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 :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Fitzcarraldo Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/32674073548b9c27b587f8.jpg)
Joined: 30 Aug 2008 Posts: 2056 Location: United Kingdom
|
Posted: Wed Apr 11, 2018 10:47 pm Post subject: Re: Cron question |
|
|
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, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC systemd-utils[udev] elogind KDE on both.
My blog |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Kurogane n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 23 May 2010 Posts: 52
|
Posted: Thu Apr 12, 2018 7:32 am Post subject: Re: Cron question |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Zucca Moderator
![Moderator Moderator](/images/ranks/rank-mod.gif)
![](images/avatars/8484577066727ff6a19116.gif)
Joined: 14 Jun 2007 Posts: 3939 Location: Rasi, Finland
|
Posted: Thu Apr 12, 2018 8:05 am Post subject: Re: Cron question |
|
|
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 :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Fitzcarraldo Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/32674073548b9c27b587f8.jpg)
Joined: 30 Aug 2008 Posts: 2056 Location: United Kingdom
|
Posted: Thu Apr 12, 2018 11:36 am Post subject: |
|
|
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, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC systemd-utils[udev] elogind KDE on both.
My blog |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Zucca Moderator
![Moderator Moderator](/images/ranks/rank-mod.gif)
![](images/avatars/8484577066727ff6a19116.gif)
Joined: 14 Jun 2007 Posts: 3939 Location: Rasi, Finland
|
Posted: Thu Apr 12, 2018 12:08 pm Post subject: |
|
|
@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 :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Fitzcarraldo Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/32674073548b9c27b587f8.jpg)
Joined: 30 Aug 2008 Posts: 2056 Location: United Kingdom
|
Posted: Thu Apr 12, 2018 1:05 pm Post subject: |
|
|
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, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC systemd-utils[udev] elogind KDE on both.
My blog |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Zucca Moderator
![Moderator Moderator](/images/ranks/rank-mod.gif)
![](images/avatars/8484577066727ff6a19116.gif)
Joined: 14 Jun 2007 Posts: 3939 Location: Rasi, Finland
|
Posted: Thu Apr 12, 2018 1:41 pm Post subject: |
|
|
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 :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Kurogane n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 23 May 2010 Posts: 52
|
Posted: Thu Apr 12, 2018 7:32 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Zucca Moderator
![Moderator Moderator](/images/ranks/rank-mod.gif)
![](images/avatars/8484577066727ff6a19116.gif)
Joined: 14 Jun 2007 Posts: 3939 Location: Rasi, Finland
|
Posted: Thu Apr 12, 2018 8:18 pm Post subject: |
|
|
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 :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
Last edited by Zucca on Fri Apr 13, 2018 7:20 am; edited 1 time in total |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Kurogane n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 23 May 2010 Posts: 52
|
Posted: Thu Apr 12, 2018 8:58 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Zucca Moderator
![Moderator Moderator](/images/ranks/rank-mod.gif)
![](images/avatars/8484577066727ff6a19116.gif)
Joined: 14 Jun 2007 Posts: 3939 Location: Rasi, Finland
|
Posted: Fri Apr 13, 2018 7:23 am Post subject: |
|
|
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 :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|