From owner-freebsd-questions@FreeBSD.ORG Wed Dec 5 11:58:16 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C80A16A417 for ; Wed, 5 Dec 2007 11:58:16 +0000 (UTC) (envelope-from derek@computinginnovations.com) Received: from betty.computinginnovations.com (mail.computinginnovations.com [64.81.227.250]) by mx1.freebsd.org (Postfix) with ESMTP id EC95213C4CC for ; Wed, 5 Dec 2007 11:58:15 +0000 (UTC) (envelope-from derek@computinginnovations.com) Received: from p28.computinginnovations.com (dhcp-10-20-30-100.computinginnovations.com [10.20.30.100]) (authenticated bits=0) by betty.computinginnovations.com (8.13.8/8.13.8) with ESMTP id lB5Bw2eq041736; Wed, 5 Dec 2007 05:58:03 -0600 (CST) (envelope-from derek@computinginnovations.com) Message-Id: <6.0.0.22.2.20071205055038.02503490@mail.computinginnovations.com> X-Sender: derek@mail.computinginnovations.com X-Mailer: QUALCOMM Windows Eudora Version 6.0.0.22 Date: Wed, 05 Dec 2007 05:57:47 -0600 To: Supote Leelasuppakorn , From: Derek Ragona In-Reply-To: References: Mime-Version: 1.0 X-ComputingInnovations-MailScanner-Information: Please contact the ISP for more information X-ComputingInnovations-MailScanner: Found to be clean X-ComputingInnovations-MailScanner-From: derek@computinginnovations.com X-Spam-Status: No Content-Type: text/plain; charset="us-ascii"; format=flowed X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: Re: Shell script in crontab cannot write files into FreeBSD's filesystem. (2nd evised version) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Dec 2007 11:58:16 -0000 At 03:02 AM 12/5/2007, Supote Leelasuppakorn wrote: >Hi all, > > Please anybody help me, I faced the problem with my "crontab". >I tried to run a shell script which will fetch webpage and save it to >a directory by using wget but after few minute I cannot see any file >in such directory > > Below are content of shell script, my crontab and also >file's permission listing. > >########################## ># Output of `crontab -l` >########################## >SHELL=/bin/sh >MAILTO=pjn >* * * * * . /home/pjn/parseGP/fetchPage.sh > > >######################## ># file: fetchPage.sh >######################## >#!/bin/sh >TIMESTAMP=`date "+%Y%m%d-%H%M%S"` You are assuming that date is in your path by the above statement. Never assume you have a good path, unless you set it in your script file. So, either setup the path you need or use absolute pathnames such as: TIMESTAMP=`/bin/date "+%Y%m%d-%H%M%S"` >LOGPATH="/home/pjn/parseGP/logs" >/usr/local/bin/wget --no-cache -a ${LOGPATH}/fetch.log -O >${LOGPATH}/${TIMESTAMP}.html http://www.blahblah.com > > >######################## ># Files' permission >######################## >blahHost$ >blahHost$ls -ltrd parseGP >drwxr-xr-x 3 pjn pjn 512 Dec 5 14:27 parseGP >blahHost$ls -ltr parseGP/ >total 4 >drwxr-xr-x 2 pjn pjn 512 Dec 5 15:11 logs >-rwxr--r-- 1 pjn pjn 226 Dec 5 15:21 fetchPage.sh >blahHost$ls -ltr parseGP/logs/ >total 0 >-rw-r--r-- 1 pjn pjn 0 Dec 5 15:14 fetch.log >blahHost$ > > > >TIA >Pote Make sure your script runs correctly outside cron, then test it from inside cron. Add some echo statements so you can see what is executed, such as: #!/bin/sh TIMESTAMP=`/bin/date "+%Y%m%d-%H%M%S"` LOGPATH="/home/pjn/parseGP/logs" echo $(TIMESTAMP) echo $(LOGPATH) echo /usr/local/bin/wget --no-cache -a ${LOGPATH}/fetch.log -O /usr/local/bin/wget --no-cache -a ${LOGPATH}/fetch.log -O echo ${LOGPATH}/${TIMESTAMP}.html http://www.blahblah.com ${LOGPATH}/${TIMESTAMP}.html http://www.blahblah.com -Derek -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks transtec Computers for their support.