[nycbug-talk] crontab woes

max max
Tue Jul 19 16:56:57 EDT 2005


You can try removing references to specific files for writing in the script and instead make it simply echo and then add  "> /filename 2>&1" at the end of the crontab line


On Tue, Jul 19, 2005 at 04:48:20PM -0400, Kevin Reiter wrote:
> All,
> 
> I'm ready to pull my hair out on this one..
> 
> I have a crontab setup to run a small shell script every day at 1:15 am. 
>  The script writes to a log so I can follow the activity, but I've 
> noticed it's empty.  When I do some further checking to see if the 
> script did what it's supposed to do, I see that it didn't run at all.
> 
> Here's the crontab entry:
> 
> root at Vulcan# crontab -l
> # Run the script every night at 1:15 AM
> 15 1 * * * /root/scripts/myscript.sh
> 
> The script is in place, is executable, and runs just fine if I do 
> ./myscript.sh
> 
> cron is running:
> 
> root at Vulcan# ps wax | grep cron
>   154  ??  Ss     0:06.88 /usr/sbin/cron
> 
> root at Vulcan# uname -a
> FreeBSD Vulcan 4.9-RELEASE FreeBSD 4.9-RELEASE #0: Sat Mar 13 10:13:57 
> EST 2004     root at Vulcan:/usr/obj/usr/src/sys/Vulcan  i386
> 
> Any ideas?  This is something so simple, yet very exhasperating.
> 
> -Kev
> 
> 
> Here's the contents of my script with sensitive info edited in { }:
> 
> #!/bin/sh
> #
> # Gets the outside IP of this machine and sends it to a secure location 
> # on the Penguin Netwerx web server to be used for remote access.
> # The only port that this requires is /usr/ports/ftp/ncftp3
> 
> # Define the DATE variable for logging
> DATE=`date +'%m-%d-%Y %H:%M:%S'`
> 
> # Get our outside IP
> fetch www.penguinnetwerx.net/ip.php
> 
> # Rename ip.php to this company
> mv ip.php {company name}
> IP=`cat {company}`
> 
> # Send the IP file to the server and log it
> ncftpput -u {username} -p {password} {server} 
> www.penguinnetwerx.net/{directory}/ {company}
> echo '' >> update_ip.log
> echo "$DATE IP updated successfully." >> update_ip.log
> echo "My IP is $IP" >> update_ip.log
> 
> # Send the e-mail notification
> echo "$DATE IP updated to $IP for {company}" > temp.email
> mail -s "IP Update for {company}" spam_me at penguinnetwerx.net < temp.email
> 
> 
> # Delete the files to avoid issues with future conections
> rm {company}
> rm temp.email
> 
> # Done.
> _______________________________________________
> % NYC*BUG talk mailing list
> http://lists.nycbug.org/mailman/listinfo/talk
> %Be sure to check out our Jobs and NYCBUG-announce lists
> %We meet the first Wednesday of the month
> 




More information about the talk mailing list