LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-20-2012, 01:33 AM   #1
educated__fool
LQ Newbie
 
Registered: Sep 2012
Location: Veles, Macedonia, Europe
Distribution: Gentoo
Posts: 6

Rep: Reputation: Disabled
cron in debian is not executing a script at the scheduled time


Hi there,

I'm new to the boards so I didn't know what is the appropriate place to post this in... if the place is wrong the mods can move the thread to its place...

anyhow, I purged arch linux from one of my vps'es and installed debian6. restored my configs and data and was up and running in no time, but...

I noticed that my cron is 'not' working as expected. what I mean by this is that it is working and executing my bash scripts but is not executing them at the time set... for example, this is what I have in my 'crontab -l':

Code:
┌─[06:37:49]-[root@gordon]-[/etc/nginx]
└─› crontab -l
@reboot echo "$(hostname)" | /usr/bin/mail -s "Server up" my@email.net

*/5  *   *   *   *  /root/bin/update_vnstat_db
# daily backup
#*/5  *   *   *   *  /usr/bin/strace /root/bin/bkpTool > /tmp/strace.cron.out
59   7   *   *   *  /usr/bin/bkpTool 2>&1 | mail -s "GORDON: Backup report => $(date)" my@email.net

#|   |   |   |   |  user command
#|   |   |   |  weekday (0-6) (Sunday=0)
#|   |   |   month (1-12)
#|   |   day (0-31)
#|   hour (0-23)
#minute (0-59)
Code:
┌─[07:25:40]-[root@gordon]-[/etc/nginx]
└─› ls -la /usr/bin/bkpTool
-rwxr-xr-x 1 root root 7333 Sep  4 07:54 /usr/bin/bkpTool
Code:
┌─[07:26:39]-[root@gordon]-[/etc/nginx]
└─› ps aux | grep -v grep | grep cron
root      1006  0.0  0.1   3816   552 ?        Ss   Sep19   0:00 /usr/sbin/cron
Code:
┌─[07:26:48]-[root@gordon]-[/etc/nginx]
└─› grep bkpTool /var/log/cron.log
Sep 16 13:59:01 gordon /USR/SBIN/CRON[3375]: (root) CMD (/usr/bin/bkpTool 2>&1 | mail -s "GORDON: Backup report => $(date)"   my@email.net)
Sep 17 13:59:01 gordon /USR/SBIN/CRON[6841]: (root) CMD (/usr/bin/bkpTool 2>&1 | mail -s "GORDON: Backup report => $(date)"   my@email.net)
Sep 18 13:59:01 gordon /USR/SBIN/CRON[20892]: (root) CMD (/usr/bin/bkpTool 2>&1 | mail -s "GORDON: Backup report => $(date)" my@email.net)
Sep 19 13:59:01 gordon /USR/SBIN/CRON[30375]: (root) CMD (/usr/bin/bkpTool 2>&1 | mail -s "GORDON: Backup report => $(date)" my@email.net)

Code:
┌─[07:26:48]-[root@gordon]-[/etc/nginx]
└─› grep bkpTool /var/log/cron.log
Sep 16 13:59:01 gordon /USR/SBIN/CRON[3375]: (root) CMD (/usr/bin/bkpTool 2>&1 | mail -s "GORDON: Backup report => $(date)"   my@email.net)
Sep 17 13:59:01 gordon /USR/SBIN/CRON[6841]: (root) CMD (/usr/bin/bkpTool 2>&1 | mail -s "GORDON: Backup report => $(date)"   my@email.net)
Sep 18 13:59:01 gordon /USR/SBIN/CRON[20892]: (root) CMD (/usr/bin/bkpTool 2>&1 | mail -s "GORDON: Backup report => $(date)" my@email.net)
Sep 19 13:59:01 gordon /USR/SBIN/CRON[30375]: (root) CMD (/usr/bin/bkpTool 2>&1 | mail -s "GORDON: Backup report => $(date)" my@email.net)
how can this be? am I missing something? the cron executes the script at 01:59 PM instead of 7:59 AM...

if someone can just sched some light to me it would be great as I'm in a `while true` loop for more than an hour trying to figure this out with no success

thanks,

- d

Last edited by educated__fool; 09-20-2012 at 01:43 AM. Reason: fixed double code tags
 
Old 09-20-2012, 01:56 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,475

Rep: Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424
What can be found int the subject of the mail sent by the cronjob? "GORDON: Backup report => $(date)"
I can only imagine some tricky timezone settings.
 
Old 09-20-2012, 01:59 AM   #3
educated__fool
LQ Newbie
 
Registered: Sep 2012
Location: Veles, Macedonia, Europe
Distribution: Gentoo
Posts: 6

Original Poster
Rep: Reputation: Disabled
Hey, pan64 thanks for your prompt reply. Here's what the subject looks like:

Code:
GORDON: Backup report => Tue Sep 18 13:59:01 CEST 2012
I checked the time zone too but anyhow:

Code:
┌─[07:58:52]-[root@gordon]-[/etc/nginx]
└─› ls -la /etc/localtime 
lrwxrwxrwx 1 root root 33 Aug 27 08:43 /etc/localtime -> /usr/share/zoneinfo/Europe/Skopje

┌─[07:58:53]-[root@gordon]-[/etc/nginx]
└─› date
Thu Sep 20 07:58:55 CEST 2012
have really no idea what's going on...
 
Old 09-20-2012, 02:03 AM   #4
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,415

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Hi educated,


You said that your script is executing but at different time. So, sure the problem is of time or time zone on your system.
 
Old 09-20-2012, 02:04 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,475

Rep: Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424
I would try to compare the environment (that means you execute set in a cronjob, save the output and compare it with set executed in a normal shell)
 
Old 09-20-2012, 02:20 AM   #6
educated__fool
LQ Newbie
 
Registered: Sep 2012
Location: Veles, Macedonia, Europe
Distribution: Gentoo
Posts: 6

Original Poster
Rep: Reputation: Disabled
i've put this to run with set -x

Code:
*/5  *   *   *   * /usr/bin/bkpTool 2>&1 | mail -s "GORDON: Backup report => $(date)" e@mail.com
and am waiting to complete and then to compare them. anyhow, here's what the env used by the cron looks like:

Code:
*/1  *   *   *   *  env > /tmp/env.cron

┌─[08:15:50]-[root@gordon]-[~]
└─› cat /tmp/env.cron 
HOME=/root
LOGNAME=root
PATH=/usr/bin:/bin
LANG=en_US.UTF-8
SHELL=/bin/sh
PWD=/root
 
Old 09-20-2012, 02:23 AM   #7
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,475

Rep: Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424Reputation: 2424
and what is the env of a normal shell?
 
Old 09-20-2012, 02:26 AM   #8
educated__fool
LQ Newbie
 
Registered: Sep 2012
Location: Veles, Macedonia, Europe
Distribution: Gentoo
Posts: 6

Original Poster
Rep: Reputation: Disabled
here's the difference between them:

Code:
┌─[08:23:35]-[root@gordon]-[~]
└─› diff -u /tmp/env.cron /tmp/env.shell 
--- /tmp/env.cron	2012-09-20 08:12:01.000000000 +0200
+++ /tmp/env.shell	2012-09-20 08:12:47.000000000 +0200
@@ -1,6 +1,55 @@
+LESS_TERMCAP_mb=
+LESS_TERMCAP_md=
+LESS_TERMCAP_me=
+MAILTO=m@email.net
+SHELL=/bin/bash
+TERM=screen
+HISTSIZE=20000
+SSH_CLIENT=XXX.XXX.XXX.XXX 43378 PORT
+LESS_TERMCAP_ue=
+SSH_TTY=/dev/pts/0
+USER=root
+TERMCAP=SC|screen|VT 100/ANSI X3.64 virtual terminal:\
+	:DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:bs:bt=\E[Z:\
+	:cd=\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:ct=\E[3g:\
+	:do=^J:nd=\E[C:pt:rc=\E8:rs=\Ec:sc=\E7:st=\EH:up=\EM:\
+	:le=^H:bl=^G:cr=^M:it#8:ho=\E[H:nw=\EE:ta=^I:is=\E)0:\
+	:li#56:co#183:am:xn:xv:LP:sr=\EM:al=\E[L:AL=\E[%dL:\
+	:cs=\E[%i%d;%dr:dl=\E[M:DL=\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ROL=ignoredups:ignorespace
 HOME=/root
+SHLVL=2
+SCREEN_CONF_DIR=/root/.screen/configs
 LOGNAME=root
-PATH=/usr/bin:/bin
-LANG=en_US.UTF-8
-SHELL=/bin/sh
-PWD=/root
+VISUAL=vim
+WINDOW=0
+SSH_CONNECTION=XXX.XXX.XXX.XXX 43378 XXX.XXX.XXX.XXX PORT
+LESS_TERMCAP_so=
+SCREEN_CONF=main
+LESS_TERMCAP_se=
+_=/usr/bin/env
+OLDPWD=/root
thanks,
 
Old 09-20-2012, 02:37 AM   #9
educated__fool
LQ Newbie
 
Registered: Sep 2012
Location: Veles, Macedonia, Europe
Distribution: Gentoo
Posts: 6

Original Poster
Rep: Reputation: Disabled
ok, this is solved by running:

Code:
┌─[08:33:16]-[root@gordon]-[~]
└─› dpkg-reconfigure tzdata
don't know why as I just re-set the same settings I set before .... Europe/Skopje and to test it set the cron to run at 08:35 and it executed just fine....

marking this as [SOLVED] ... what a waste of time ... but still interesting ....

thank you all for your inputs.

take care,

- d

EDIT: Sorry, but how would I go editing the subject and appending [SOLVED] to it?
EDIT2: Ok, found it at the top-right ..... I'm kinda tired was working 3rd shift all night long ...

Last edited by educated__fool; 09-20-2012 at 02:41 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing a script at boot time digilink Linux - Server 3 04-22-2011 08:21 PM
[SOLVED] Running scheduled script with cron snadjari Linux - Newbie 5 03-04-2011 03:39 PM
Bash script run via cron not executing MYSQL command mackstar Linux - Server 4 04-23-2009 06:01 AM
Cron not Executing PHP script Badnoodles Linux - General 2 10-25-2006 05:56 PM
executing a time-triggered script leosuth Programming 7 06-02-2004 09:15 AM


All times are GMT -5. The time now is 12:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration