View previous topic :: View next topic |
Author |
Message |
emc Guru
Joined: 02 Jul 2004 Posts: 564 Location: Cracow, Poland
|
Posted: Mon Mar 04, 2013 1:37 pm Post subject: [solved] frcon doesn't run all scripts in /etc/cron.{}/ |
|
|
Hi,
Since I have a laptop I choose fcron to sync emerge tree:
Code: | # ls -l /etc/cron.daily/
total 20
-rwxr-xr-x 1 root root 42 Feb 26 10:05 check_updates
-rwxr-xr-x 1 root root 52 Feb 4 18:49 logrotate.cron
-rwxr-xr-x 1 root root 115 Dec 14 23:55 makewhatis
-rwxr-xr-x 1 root root 1297 Dec 20 22:48 mlocate
-rwxr-xr-x 1 root root 2424 Jan 28 2012 prelink |
but i syslog I can see only:
Code: | # grep -i daily /var/log/messages
Mar 3 03:10:00 gopher run-crons[30296]: (root) CMD (/etc/cron.daily/makewhatis)
Mar 3 03:10:02 gopher run-crons[30345]: (root) CMD (/etc/cron.daily/mlocate)
Mar 3 10:58:16 gopher run-crons[2252]: (root) CMD (/etc/cron.daily/prelink)
Mar 4 08:50:00 gopher run-crons[6190]: (root) CMD (/etc/cron.daily/logrotate.cron)
Mar 4 08:50:01 gopher run-crons[6195]: (root) CMD (/etc/cron.daily/makewhatis)
Mar 4 08:50:02 gopher run-crons[6245]: (root) CMD (/etc/cron.daily/mlocate)
Mar 4 08:50:02 gopher run-crons[6250]: (root) CMD (/etc/cron.daily/prelink) |
Here is my crontab for root:
Code: | # crontab -l
2013-03-04 14:35:16 INFO listing root's fcrontab
# for fcron
# $Header: /var/cvsroot/gentoo-x86/sys-process/fcron/files/crontab,v 1.2 2009/05/12 09:21:58 bangert Exp $
# fcron:
# This is NOT the system crontab! fcron does not support a system crontab.
# to get /etc/cron.{hourly|daily|weekly|montly} working with fcron run
# crontab /etc/crontab
# as root.
# NOTE: This will REPLACE root's current crontab!!
# Global variables
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
59 * * * * root rm -f /var/spool/cron/lastrun/cron.hourly
9 3 * * * root rm -f /var/spool/cron/lastrun/cron.daily
19 4 * * 6 root rm -f /var/spool/cron/lastrun/cron.weekly
29 5 1 * * root rm -f /var/spool/cron/lastrun/cron.monthly
*/10 * * * * root test -x /usr/sbin/run-crons && /usr/sbin/run-crons |
Last edited by emc on Wed Mar 20, 2013 11:20 am; edited 1 time in total |
|
Back to top |
|
|
emc Guru
Joined: 02 Jul 2004 Posts: 564 Location: Cracow, Poland
|
Posted: Fri Mar 15, 2013 12:32 pm Post subject: |
|
|
I've add (see last line):
Code: | # crontab -l
2013-03-15 13:27:16 INFO listing root's fcrontab
# for fcron
# $Header: /var/cvsroot/gentoo-x86/sys-process/fcron/files/crontab,v 1.2 2009/05/12 09:21:58 bangert Exp $
# fcron:
# This is NOT the system crontab! fcron does not support a system crontab.
# to get /etc/cron.{hourly|daily|weekly|montly} working with fcron run
# crontab /etc/crontab
# as root.
# NOTE: This will REPLACE root's current crontab!!
# Global variables
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# minutes (0-59)
# hours (0-23)
# days of the month (1-31)
# months (1-12)
# days of the week (0-7, Monday is 1, Sunday is 0 and 7)
# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
59 * * * * root rm -f /var/spool/cron/lastrun/cron.hourly
9 3 * * * root rm -f /var/spool/cron/lastrun/cron.daily
19 4 * * 6 root rm -f /var/spool/cron/lastrun/cron.weekly
29 5 1 * * root rm -f /var/spool/cron/lastrun/cron.monthly
*/10 * * * * root test -x /usr/sbin/run-crons && /usr/sbin/run-crons
25 12 * * 5 nice -n 20 check_updates
|
but check_updates is terminated after 2 sec:
Code: | # grep check_updates /var/log/messages
Mar 15 12:25:00 gopher fcron[16835]: Job nice -n 20 check_updates started for user root (pid 16836)
Mar 15 12:25:02 gopher fcron[16835]: Job nice -n 20 check_updates terminated (exit status: 127) (mailing output) |
and it's located here:
Code: | # ls -la /usr/local/sbin/check_updates
-rwxr-xr-x 1 root root 397 Feb 28 10:23 /usr/local/sbin/check_updates |
Script check_updates is running perfect when I run it manually:
Code: | cat /usr/local/sbin/check_updates
#!/bin/bash
> ~emc/logs/emerge.data.log
> ~emc/logs/emerge.log
date >> ~emc/logs/emerge.data.log
if [ $# -eq 0 ]; then
layman -SN >> ~emc/logs/emerge.data.log
eix-sync -q >> ~emc/logs/emerge.data.log
fi
emerge -pvNDu --with-bdeps=y --color n world >> ~emc/logs/emerge.log
cat ~emc/logs/emerge.log >> ~emc/logs/emerge.data.log
cat ~emc/logs/emerge.log | genlop -pn >> ~emc/logs/emerge.data.log |
|
|
Back to top |
|
|
Veldrin Veteran
Joined: 27 Jul 2004 Posts: 1945 Location: Zurich, Switzerland
|
Posted: Fri Mar 15, 2013 1:01 pm Post subject: |
|
|
check the environment, and especially the PATH variable, while running it as cronjob.
I vaguely remember, that PATH for cron is comparably empty. _________________ read the portage output!
If my answer is too concise, ask for an explanation. |
|
Back to top |
|
|
emc Guru
Joined: 02 Jul 2004 Posts: 564 Location: Cracow, Poland
|
Posted: Fri Mar 15, 2013 1:09 pm Post subject: |
|
|
I've check:
Code: | # cat ~/dead.letter | tail
nice: check_updates: No such file or directory
Job nice -n 20 check_updates terminated (exit status: 127) (mailing output) |
and adding full path to crontab solved the issue, but still I can't run scripts from /etc/cron.*/ directory |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Fri Mar 15, 2013 2:01 pm Post subject: |
|
|
emc ...
Basically, with fcron 'systab' (ie what is generally run as /etc/crontab) is not root's crontab, note that /etc/crontab states "this is not the system crontab!". So, I think you may have added /etc/crontab as root's crontab.
Code: | # whoami
root
# crontab -l
2013-03-15 14:40:52 INFO listing root's fcrontab
2013-03-15 14:40:52 INFO user root has no fcrontab. |
Also, the method used by fcron to handle the (system) crontab is dependent on the 'system-crontab' useflag, the behavior will differ dependent on the useflag (check the ebuild for details).
With '+system-crontab' the method of creating the 'systab' is to run 'emerge --configure sys-process/fcron' ... a /var/spool/fcron/systab should be created with the content of the current (system) /etc/crontab.
In your case I'm inclined to think that system-crontab is disabled ... but I'm not entirely sure.
best ... khay |
|
Back to top |
|
|
emc Guru
Joined: 02 Jul 2004 Posts: 564 Location: Cracow, Poland
|
Posted: Mon Mar 18, 2013 9:40 am Post subject: |
|
|
I'm not 100% sure if I understood you. I have:
Code: | # eix -I fcron
[I] sys-process/fcron
Available versions: 3.0.6-r1 ~3.0.6-r5 ~3.1.0 3.1.1 {{debug linguas_fr pam readline selinux +system-crontab}}
Installed versions: 3.1.1(09:24:37 AM 02/19/2013)(pam readline system-crontab -debug -linguas_fr -selinux)
Homepage: http://fcron.free.fr/
Description: A command scheduler with extended capabilities over cron and anacron |
So, should I use crontab for regular user (not root):
Code: | # crontab /etc/crontab -u emc
2013-03-18 10:33:21 INFO installing file /etc/crontab for user emc
Modifications will be taken into account right now. |
Code: | # crontab -l -u emc
2013-03-18 10:33:29 INFO listing emc's fcrontab
# for fcron
# $Header: /var/cvsroot/gentoo-x86/sys-process/fcron/files/crontab,v 1.2 2009/05/12 09:21:58 bangert Exp $
# fcron:
# This is NOT the system crontab! fcron does not support a system crontab.
# to get /etc/cron.{hourly|daily|weekly|montly} working with fcron run
# crontab /etc/crontab
# as root.
# NOTE: This will REPLACE root's current crontab!!
# Global variables
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
59 * * * * root rm -f /var/spool/cron/lastrun/cron.hourly
9 3 * * * root rm -f /var/spool/cron/lastrun/cron.daily
19 4 * * 6 root rm -f /var/spool/cron/lastrun/cron.weekly
29 5 1 * * root rm -f /var/spool/cron/lastrun/cron.monthly
*/10 * * * * root test -x /usr/sbin/run-crons && /usr/sbin/run-crons |
I had and have crontab in /var/...:
Code: | gopher crontabs # pwd
/var/spool/cron/crontabs
gopher crontabs # ls
emc root |
Code: | # cat root
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXXXWa45Mp installed on Mon Feb 11 18:08:30 2013)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
# for vixie cron
# $Header: /var/cvsroot/gentoo-x86/sys-process/vixie-cron/files/crontab-3.0.1-r4,v 1.3 2011/09/20 15:13:51 idl0r Exp $
# Global variables
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
59 * * * * root rm -f /var/spool/cron/lastrun/cron.hourly
9 3 * * * root rm -f /var/spool/cron/lastrun/cron.daily
19 4 * * 6 root rm -f /var/spool/cron/lastrun/cron.weekly
29 5 1 * * root rm -f /var/spool/cron/lastrun/cron.monthly
*/10 * * * * root test -x /usr/sbin/run-crons && /usr/sbin/run-crons |
Code: | # cat emc
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXXX2J7Afz installed on Mon Feb 18 17:19:45 2013)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
# for vixie cron
# $Header: /var/cvsroot/gentoo-x86/sys-process/vixie-cron/files/crontab-3.0.1-r4,v 1.3 2011/09/20 15:13:51 idl0r Exp $
# Global variables
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
59 * * * * root rm -f /var/spool/cron/lastrun/cron.hourly
9 3 * * * root rm -f /var/spool/cron/lastrun/cron.daily
19 4 * * 6 root rm -f /var/spool/cron/lastrun/cron.weekly
29 5 1 * * root rm -f /var/spool/cron/lastrun/cron.monthly
*/10 * * * * root test -x /usr/sbin/run-crons && /usr/sbin/run-crons |
|
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Mon Mar 18, 2013 10:35 am Post subject: |
|
|
emc wrote: | So, should I use crontab for regular user (not root): |
emc ... well, no, the 'system crontab' ('systab'), ie, what runs /etc/cron.{hourly,daily,weekly,monthly} and so all the package installed scripts therein, should be seperate from roots crontab (ie: that listed above with 'crontab -l'). When installing fcron you are einfo'd to run 'emerge --configure sys-process/fcron' which will take the content of 'system crontab' (/etc/crontab) and make a 'systab', /var/spool/fcron/systab, this is the 'crontab' that fcron will run for 'system crontab'. The other users can of course have their own crontabs, and these will show up as /var/spool/fcron/$(USER}.
I'm guessing the issues your having is that there are mulitple crontabs that run the same 'systab' at the same scheduled time. Actually, I'm not really sure whats happening, or why the content of /etc/cron.* isn't run ... but you seem to have the above misconfigured, so its no doubt a good idea to fix that before proceeding to debug it further.
I'd suggest stopping fcron, removing whatever currently exists in /var/spool/fcron, and running 'emerge --configure sys-process/fcron', once fcron is again started your 'systab' should run without issues, and the various users have empty crontabs.
Code: | % whoami
khayyam
% crontab -l
2013-03-18 11:24:14 INFO listing khayyam's fcrontab
2013-03-18 11:24:14 INFO user khayyam has no fcrontab.
% su -
# whoami
root
# crontab -l
2013-03-18 11:24:17 INFO listing root's fcrontab
2013-03-18 11:4:17 INFO user root has no fcrontab. |
emc wrote: | Code: | # cat emc
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXXX2J7Afz installed on Mon Feb 18 17:19:45 2013)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
# for vixie cron |
|
Note: this is for 'vixie-cron' ...
best ... khay |
|
Back to top |
|
|
emc Guru
Joined: 02 Jul 2004 Posts: 564 Location: Cracow, Poland
|
Posted: Wed Mar 20, 2013 10:10 am Post subject: |
|
|
Ok, it's getting clear, so what I did:
Code: | # cd -
/var/spool/fcron
# ls -la
total 16
drwsrws--- 2 fcron fcron 4096 Mar 20 10:56 .
drwxr-xr-x 6 root root 4096 Feb 19 09:24 ..
-rw-r--r-- 1 root root 0 Mar 20 10:54 .keep_sys-process_fcron-0 |
then:
Code: | # emerge --config sys-process/fcron
Configuring pkg...
* This is going to set up fcron to execute check_system_crontabs.
* In this configuration, you're no longer free to edit the systab
* at your leisure, at it'll be rewritten the moment the crontabs
* are modified.
Rebuilding fcron systab.
2013-03-20 10:56:59 INFO installing file /tmp/fcrontab.mELKrJ for user systab
Modifications will be taken into account right now. |
check:
Code: | # crontab -l
2013-03-20 10:58:32 INFO listing root's fcrontab
2013-03-20 10:58:32 INFO user root has no fcrontab.
# crontab -l -u emc
2013-03-20 10:58:37 INFO listing emc's fcrontab
2013-03-20 10:58:37 INFO user emc has no fcrontab. |
and content of /var/spool/fcron:
Code: | # cd -
/var/spool/fcron
# ls -la
total 16
drwsrws--- 2 fcron fcron 4096 Mar 20 10:56 .
drwxr-xr-x 6 root root 4096 Feb 19 09:24 ..
-rw-r--r-- 1 root root 0 Mar 20 10:54 .keep_sys-process_fcron-0
-rw------- 1 root root 832 Mar 20 10:56 systab
-rw------- 1 root fcron 1674 Mar 20 10:56 systab.orig
# cat systab
dsysta#IQ#SHELL=/bin/bash#"PATH=/sbin:/bin:/usr/sbin:/usr/bin#HOME=/#)rm -f /var/spool/cron/lastrun/cron.hourly#root#root#d#I###############(rm -f /var/spool/cron/lastrun/cron.daily#root#root##kJQ###########)rm -f /var/spool/cron/lastrun/cron.weekly#root#root#$M#########@##*rm -f /var/spool/cron/lastrun/cron.monthly#root#root##XQ # #######2test -x /usr/sbin/run-crons && /usr/sbin/run-crons#root#root###IQ@###############'/usr/libexec/check_system_crontabs -s 0#root#root##@#IX# |
And now I have question, since I'm running laptop so to best to my knowledge fcron is better (for system which can be turned off when cron task is scheduled) but in /etc/crontab I see:
Code: | # cat /etc/crontab
# for fcron
# $Header: /var/cvsroot/gentoo-x86/sys-process/fcron/files/crontab,v 1.3 2013/03/03 16:28:06 wschlich Exp $
# fcron:
# This is NOT the system crontab! fcron does not support a system crontab.
# to get /etc/cron.{hourly|daily|weekly|montly} working with fcron run
# crontab /etc/crontab
# as root.
# NOTE: This will REPLACE root's current crontab!!
# Global variables
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
59 * * * * rm -f /var/spool/cron/lastrun/cron.hourly
9 3 * * * rm -f /var/spool/cron/lastrun/cron.daily
19 4 * * 6 rm -f /var/spool/cron/lastrun/cron.weekly
29 5 1 * * rm -f /var/spool/cron/lastrun/cron.monthly
*/10 * * * * test -x /usr/sbin/run-crons && /usr/sbin/run-crons |
So, should I run crontab /etc/crontab as root to get script from /etc/cron.{hourly|daily|weekly|montly} running? |
|
Back to top |
|
|
emc Guru
Joined: 02 Jul 2004 Posts: 564 Location: Cracow, Poland
|
Posted: Wed Mar 20, 2013 11:18 am Post subject: |
|
|
I think text in /etc/crontam is misleading:
Quote: | # fcron:
# This is NOT the system crontab! fcron does not support a system crontab.
# to get /etc/cron.{hourly|daily|weekly|montly} working with fcron run
# crontab /etc/crontab
# as root.
# NOTE: This will REPLACE root's current crontab!! |
Because system crontab is working without run: crontab /etc/crontab. I add some scripts into /etc/cron.hourly and they was successfully executed and there are entries in /var/log/messages. Anyway this close the topic
khay thx for clarification and help |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Wed Mar 20, 2013 11:19 am Post subject: |
|
|
emc wrote: | So, should I run crontab /etc/crontab as root to get script from /etc/cron.{hourly|daily|weekly|montly} running? |
emc ... no need as the content of /etc/crontab has been transfered to the 'systab'. That note in /etc/crontab is a little bit misleading as when you install fcron, and /etc/crontab is installed, you are prompted to run 'emerge --configure sys-process/fcron', so following both suggestions you would replicate the content of /etc/crontab in 'systab' and in roots crontab.
EDIT: hehe ... I see you posted seconds before I made my reply.
best ... khay |
|
Back to top |
|
|
emc Guru
Joined: 02 Jul 2004 Posts: 564 Location: Cracow, Poland
|
Posted: Wed Mar 27, 2013 3:27 pm Post subject: |
|
|
I know it's solved but I have one more question... where can I change hour and minutes when {hourly|daily|weekly|montly} is started. Right now form daily is around 17:40:
Code: | # grep cron.daily /var/log/messages
Mar 24 17:30:01 gopher run-crons[8583]: (root) CMD (/etc/cron.daily/makewhatis)
Mar 24 17:30:02 gopher run-crons[8636]: (root) CMD (/etc/cron.daily/mlocate)
Mar 24 17:30:02 gopher run-crons[8641]: (root) CMD (/etc/cron.daily/prelink)
Mar 25 17:40:00 gopher run-crons[15168]: (root) CMD (/etc/cron.daily/chk_upd)
Mar 25 17:44:46 gopher run-crons[21136]: (root) CMD (/etc/cron.daily/logrotate.cron)
Mar 25 17:44:46 gopher run-crons[21140]: (root) CMD (/etc/cron.daily/makewhatis)
Mar 25 17:44:49 gopher run-crons[21444]: (root) CMD (/etc/cron.daily/mlocate)
Mar 25 17:44:50 gopher run-crons[21455]: (root) CMD (/etc/cron.daily/prelink)
Mar 26 17:50:00 gopher run-crons[12889]: (root) CMD (/etc/cron.daily/chk_upd)
Mar 26 17:56:53 gopher run-crons[20087]: (root) CMD (/etc/cron.daily/logrotate.cron)
Mar 26 17:56:53 gopher run-crons[20091]: (root) CMD (/etc/cron.daily/makewhatis)
Mar 26 17:56:56 gopher run-crons[20307]: (root) CMD (/etc/cron.daily/mlocate)
Mar 26 17:58:04 gopher run-crons[20527]: (root) CMD (/etc/cron.daily/prelink)
Mar 26 23:46:49 gopher sudo: emc : TTY=pts/3 ; PWD=/home/emc ; USER=root ; COMMAND=/bin/ls -l /etc/cron.allow /etc/cron.daily /etc/cron.hourly /etc/cron.monthly /etc/cron.weekly |
|
|
Back to top |
|
|
|
|
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
|
|