LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-18-2008, 02:32 AM   #1
gary4gar
Member
 
Registered: Aug 2006
Location: India
Distribution: Arch Linux x86_64 KDEmod 4.1
Posts: 52

Rep: Reputation: 15
Exclamation Finding & fixing problem with cron


i schedule my downloads with cron, but from past few, it isn't working(no downloads). and i need to help to first find the the problem & then fixing it.

my crontab looks like

Code:
# m h  dom mon dow   command
10 2 * * * cd /home/gaurish/scripts && sh router-reboot.sh | telnet
10 2 * * * DISPLAY=:0.0 /opt/azureus/azureus
13 2 * * * wget -ci /home/gaurish/dl-list.txt
50 7 * * * cd /home/gaurish/scripts && sh router-reboot.sh | telnet
Root's crontab
Code:
50 7 * * * /sbin/shutdown -h 0
mail from from cron
Quote:
From: Cron Daemon <root@moody-machine>
To: gaurish@moody-machine
Subject: Cron <gaurish@MOODY-MACHINE> cd /home/gaurish/scripts && sh router-reboot.sh | telnet
Date: Fri, 18 Jan 2008 02:10:05 +0530


telnet> Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.

BusyBox on localhost login: root
Password:


BusyBox v0.61.pre (2006.06.30-13:40+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

# reboot
Connection closed by foreign host.
^^^
i think its done successfully

Quote:
From: Cron Daemon <root@moody-machine>
To: gaurish@moody-machine
Subject: Cron <gaurish@MOODY-MACHINE> wget -ci /home/gaurish/dl-list.txt
Date: Fri, 18 Jan 2008 02:14:00 +0530


--02:13:01-- http://download-secondlife-com.s3.am...18_5_3.tar.bz2
=> `SecondLife_i686_1_18_5_3.tar.bz2'
Resolving download-secondlife-com.s3.amazonaws.com... failed: Name or service not known.
--02:13:57-- http://www.linuxcafe.org/uu/ubuntu-ultimate-1.6-dvd.iso
=> `ubuntu-ultimate-1.6-dvd.iso'
Resolving www.linuxcafe.org... 208.113.188.83
Connecting to www.linuxcafe.org|208.113.188.83|:80... failed: No route to host.

the contents of dl-list.txt file

the surprizeing part here is
1) cron started wget but for some reason downloads didn't start
2) azureus didn't come up & cron didn't even leave a mail behind stating what error



I am not sure whats wrong here, but the the reasons may be
1) network is was not up when wget was running.
2) some error in crontab config
3) cron deamon died
4) some unforeseen error happened


the script i use to reboot my router is
Code:
#!/bin/sh
add='open 192.168.1.1'
userid='root'
password='eatmypissyoublackslut'
cmd='reboot'
echo $add
sleep 1
echo $userid
sleep 1
echo $password
sleep 1
echo $cmd
sleep 1
Lastly, you guys would ask why i want to schedule eveyrthing?
Ans: My ISP gives free downloads & uploads in night, but timming is 2 am , so i wanted to sleep as well as keep my downloads going.

Last edited by gary4gar; 01-18-2008 at 02:35 AM.
 
Old 01-18-2008, 06:10 PM   #2
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
while you wait for a better reply.

wget -c option may be wrong see man wget

wget starts so we know the wget -i works....kind of

2) I prefer sequential crontabs just a suggestion add a minute to those close ones

3) but I am interested in why you have this router command.

I have a router....its left on....and my computer is shutdown.

4) leaping ahead, as a temporary measure only, you could add more crontabs around 2am to check your network is up and your firewall is up and mail it to you. Also, wget can use a log so you can see what is going wrong other than just your current wget fail messages.

I will have a look at some crontabs for my system if you like, but I use Shorewall.

5) And altho it may be clear to you, do you have any power management running when you go off to have a sleep....be it hibernate / suspend to ram/ or simple power stuff.
 
Old 01-18-2008, 06:19 PM   #3
damonhart
LQ Newbie
 
Registered: Nov 2007
Posts: 22

Rep: Reputation: 15
network diagnostics necessary

The wget failures that you do see via the cron email are definitely network errors. In the first effort you see a DNS failure and in the second a DNS lookup succeeds but the target is unreachable. With respect to azureus not starting, this could also be a network issue, particularly as it appears to be set to start at the same time as your router-reboot.sh (presumably the prerequisite for connectivity?) The router reset probably takes a little bit of time (the cron mail has a timestamp 5 seconds after the script launch.)

You might want to bundle your download efforts with a small script of networking diagnostics to clarify your issues, e.g.

/sbin/route -n
/usr/bin/dig download-secondlife-com.s3.amazonaws.com
/bin/ping -c 5 www.yahoo.com
 
Old 01-18-2008, 10:36 PM   #4
gary4gar
Member
 
Registered: Aug 2006
Location: India
Distribution: Arch Linux x86_64 KDEmod 4.1
Posts: 52

Original Poster
Rep: Reputation: 15
here is the output of today morning, now today morning:

1) today only the router reboot script ran & other :s

Quote:
From: Cron Daemon <root@moody-machine>
To: gaurish@moody-machine
Subject: Cron <gaurish@MOODY-MACHINE> cd /home/gaurish/scripts && sh router-reboot.sh | telnet
Date: Sat, 19 Jan 2008 02:10:05 +0530


telnet> Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.

BusyBox on localhost login: root
Password:


BusyBox v0.61.pre (2006.06.30-13:40+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

# reboot
Connection closed by foreign host.
wonder why the other commands didn't run

Quote:
1. check if ur DNS entries are up and running. Add opendns entries if u wish.
i am using opendns+Dnsmasq
Code:
:~$ cat /etc/resolv.conf
# generated by NetworkManager, do not edit!
nameserver 127.0.0.1
nameserver 208.67.220.220
nameserver 208.67.222.222
Quote:
2. Check ur gateway entry.
how to check?

Quote:
It cud also be ur ISP => down for maintenence!
how come, got two days at a stretch, btw BSNL in good in terms of Uptime


Quote:
1) Remote server is down
2) Problem with your ISP's DNS.
maybe, but how can you explain, tasks run run by cron & no mail left behind?
 
Old 01-18-2008, 10:58 PM   #5
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
have not read your last reply just thought I would run a test crontab to show you a working copy.

1) contents of dl-list.txt....nice and simple to be fast
http://www.abc.net.au/news/stories/2...19/2142210.htm
http://www.abc.net.au/news/stories/2...19/2142198.htm

2) /etc/crontab line
52 13 * * * root /usr/bin/wget -o log -i /home/gordy/dl-list.txt

yes I know thats not 2 am

3) Have not got the -P to work so files are dl to /

ignoring folders they are
2142198.htm
2142210.htm
log

4) log contents

--13:52:01-- http://www.abc.net.au/news/stories/2...19/2142210.htm
=> `2142210.htm'
Resolving www.abc.net.au... 150.101.98.77, 150.101.98.69
Connecting to www.abc.net.au|150.101.98.77|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 18,555 (18K) [text/html]

0K .......... ........ 100% 56.6K

13:52:02 (56.49 KB/s) - `2142210.htm' saved [18555/18555]

--13:52:02-- http://www.abc.net.au/news/stories/2...19/2142198.htm
=> `2142198.htm'
Reusing existing connection to www.abc.net.au:80.
HTTP request sent, awaiting response... 200 OK
Length: 15,831 (15K) [text/html]

0K .......... ..... 100% 57.7K

13:52:03 (57.59 KB/s) - `2142198.htm' saved [15831/15831]


FINISHED --13:52:03--
Downloaded: 34,386 bytes in 2 files


and as Damon will hopefully deduce, my dns was resolving.
 
Old 01-19-2008, 01:38 AM   #6
gary4gar
Member
 
Registered: Aug 2006
Location: India
Distribution: Arch Linux x86_64 KDEmod 4.1
Posts: 52

Original Poster
Rep: Reputation: 15
[Update]
To make Things some wierd, last night my downloads started but i didn't get a mail from cron about there status.

i can say so because as some of the file have been downloaded successfully.

now, i can't figure out whats wrong in here?
 
Old 01-19-2008, 01:44 AM   #7
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
What I would like you to do is....run this crontab...time only 2 minutes into future and only if it works reset the time of first job to 00 02
but the current times I want you to make 1 minute increments, I assume you know how.



mm hh * * * root /sbin/shorewall status | /bin/mail -s "fw 'uname -n'" root
mm hh * * * root /etc/sysconfig/network-scripts/ifdown eth0
mm hh * * * root /etc/sysconfig/network-scripts/ifup eth0
mm hh * * * root /sbin/ifconfig eth0 | /bin/mail -s "eth 'uname -n'" root
mm hh * * * root /usr/bin/wget -o log -i /home/gordy/dl-list.txt.......rename and use simple downloads


running mail I get this header info
1 root Sat Jan 19 16:22 23/646 fw 'uname -n'
2 Cron Daemon Sat Jan 19 16:24 22/659 Cron <root@gs> /etc/sysconfig/network-scripts
3 root Sat Jan 19 16:25 28/1051 eth 'uname -n'

not sure why only one nw script shows but

mail 1
Shorewall-3.4.4 Status at gs.net - Sat Jan 19 16:22:01 WST 2008

Shorewall is running

mail 2
Determining IP information for eth0... done

-----note this is a eth0 up message


mail 3
eth0 Link encap:Ethernet HWaddr 00:0F:EA:53:32:06
inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20f:eaff:fe53:3206/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1492 Metric:1
RX packets:980 errors:0 dropped:0 overruns:0 frame:0
TX packets:1150 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:810417 (791.4 KiB) TX bytes:252826 (246.9 KiB)
Interrupt:18 Base address:0x4000
------------------------------------------------------------------------------------

Now you see my eth0 addr second line....thats my gateway.


2) if when you run ifconfig manually you can not see a gateway follow these instructions
http://www.hep.wisc.edu/~pinghc/Linu...kingConfig.htm


3) naturally the last job worked but with diff timestamps in log /log


4) you may note I have ignored your router cronjob as I do not understand it and am trying to help you do the least hardware changes in trouble shooting.

ignore me if you like ....just tell me ....I am thick skinned
 
Old 01-19-2008, 07:09 AM   #8
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
oh forgot to mention I use Mdv and the pathways I show for the executables may not be your pathways. so use find

find / -name (command).....replace command with you what you are looking for.
You may get more than one pathway...but normally it will end in bin except your netwk scripts may be under a different up or down folder in /etc
 
Old 01-19-2008, 01:52 PM   #9
gary4gar
Member
 
Registered: Aug 2006
Location: India
Distribution: Arch Linux x86_64 KDEmod 4.1
Posts: 52

Original Poster
Rep: Reputation: 15
Thanks for helping, here is my changed crontab
Code:
# m h  dom mon dow   command
10 2 * * * cd /home/gaurish/scripts && sh router-reboot.sh | telnet
11 2 * * * DISPLAY=:0.0 /opt/azureus/azureus
12 2 * * * /home/gaurish/scripts/debug-call.sh
13 2 * * * /usr/bin/wget -ci /home/gaurish/dl-list.txt -o wget-log
49 7 * * * cd /home/gaurish/scripts && sh router-reboot.sh | telnet

i wrote a debug script named debug-call.sh
Code:
#!/bin/bash
/sbin/ifconfig eth0 | /usr/bin/mail -s "eth 'uname -n'" root 
/bin/ping -c 5 www.google.com
/bin/ping -c 5 192.168.1.1 #my gateway or router's address
/sbin/route -n
me waiting for 2am now.
now lets see, what happens


@aus9
thanks for you kind help
Please see, and tell what else changes to i require
 
Old 01-19-2008, 10:17 PM   #10
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
not sure why you refused to test crontabs before 2am....I will have to be blunter in telling you why it makes good sense.

I have not seen your ifconfig output to confirm your gateaway is correctly configged. Gee that would have happened with my 2 minutes into future crontab....so when you post your results pls re-run ifconfig to be sure to be sure.

2) are you trying to access this computer remotely?

telnet is not regarded as secure.
 
Old 01-20-2008, 10:00 AM   #11
gary4gar
Member
 
Registered: Aug 2006
Location: India
Distribution: Arch Linux x86_64 KDEmod 4.1
Posts: 52

Original Poster
Rep: Reputation: 15
here is todays mail from cron.

Quote:
From: Cron Daemon <root@moody-machine>
To: gaurish@moody-machine
Subject: Cron <gaurish@MOODY-MACHINE> cd /home/gaurish/scripts && sh router-reboot.sh | telnet
Date: Sun, 20 Jan 2008 02:10:06 +0530


telnet> Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.

BusyBox on localhost login: root
Password:


BusyBox v0.61.pre (2006.06.30-13:40+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

# reboot
Connection closed by foreign host.

Quote:
From: Gaurish Sharma <gaurish@moody-machine>
To: root@moody-machine
Subject: eth 'uname -n'
Date: Sun, 20 Jan 2008 02:12:01 +0530


eth0 Link encap:Ethernet HWaddr 00:11:09:06:18:C6
inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::211:9ff:fe06:18c6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9235 errors:0 dropped:0 overruns:0 frame:0
TX packets:9757 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8340418 (7.9 MB) TX bytes:1435123 (1.3 MB)
Interrupt:19 Base address:0xed00
Quote:
From: Cron Daemon <root@moody-machine>
To: gaurish@moody-machine
Subject: Cron <gaurish@MOODY-MACHINE> /home/gaurish/scripts/debug-call.sh
Date: Sun, 20 Jan 2008 02:12:06 +0530


PING google.navigation.opendns.com (208.67.217.230) 56(84) bytes of data.
64 bytes from google.navigation.opendns.com (208.67.217.230): icmp_seq=1 ttl=48 time=322 ms
64 bytes from google.navigation.opendns.com (208.67.217.230): icmp_seq=2 ttl=48 time=322 ms
64 bytes from google.navigation.opendns.com (208.67.217.230): icmp_seq=3 ttl=48 time=322 ms
64 bytes from google.navigation.opendns.com (208.67.217.230): icmp_seq=4 ttl=48 time=322 ms
64 bytes from google.navigation.opendns.com (208.67.217.230): icmp_seq=5 ttl=48 time=321 ms

--- google.navigation.opendns.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3999ms
rtt min/avg/max/mdev = 321.997/322.293/322.679/0.572 ms
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=255 time=3.54 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=255 time=0.665 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=255 time=0.660 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=255 time=0.623 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=255 time=0.622 ms

--- 192.168.1.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 3999ms
rtt min/avg/max/mdev = 0.622/1.223/3.547/1.162 ms


Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0
0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 eth0
Quote:
From: Cron Daemon <root@moody-machine>
To: gaurish@moody-machine
Subject: Cron <gaurish@MOODY-MACHINE> cd /home/gaurish/scripts && sh router-reboot.sh | telnet
Date: Sun, 20 Jan 2008 07:49:05 +0530


telnet> Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.

BusyBox on localhost login: root
Password:


BusyBox v0.61.pre (2006.06.30-13:40+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

# reboot
Connection closed by foreign host.
  • now today, azureus didn't fire up or it did :S
    but there were no downloads
  • wget fired, as i can see in wget log but there was no mail from cron

Quote:
not sure why you refused to test crontabs before 2am....I will have to be blunter in telling you why it makes good sense.

I have not seen your ifconfig output to confirm your gateaway is correctly configged. Gee that would have happened with my 2 minutes into future crontab....so when you post your results pls re-run ifconfig to be sure to be sure.

Code:
gaurish@MOODY-MACHINE:~$ ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:11:09:06:18:C6  
          inet addr:192.168.1.3  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::211:9ff:fe06:18c6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:37211 errors:0 dropped:0 overruns:0 frame:0
          TX packets:56207 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:7975912 (7.6 MB)  TX bytes:52386964 (49.9 MB)
          Interrupt:19 Base address:0xed00 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:618 errors:0 dropped:0 overruns:0 frame:0
          TX packets:618 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:46520 (45.4 KB)  TX bytes:46520 (45.4 KB)

for running it at 2am: this way i can actually test it in real conditions

Last edited by gary4gar; 01-20-2008 at 10:03 AM.
 
  


Reply

Tags
bsnl



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
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U SUSE / openSUSE 11 01-04-2007 01:57 AM
Need help fixing permissions problem. M$ISBS Linux - Security 4 12-25-2006 02:17 PM
Need help fixing grub related problem joint Linux - Software 4 12-08-2006 09:20 AM
logrotate && cron pH* Linux - General 9 12-21-2004 10:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:45 PM.

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
Open Source Consulting | Domain Registration