LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices


Reply
  Search this Thread
Old 05-11-2010, 04:06 AM   #1
Vimuth
Member
 
Registered: Sep 2009
Posts: 59

Rep: Reputation: 15
Curl utility doesnt work on freebsd crontab.


Dear All,
Following is a simple shell script I've written in order to upload a file on to a ftp server using "curl". When I run this manually the system compress the files and send the tar ball on to the FTP location without any hassle. However when I put this script on crotab the line containing the ftp upload doesn happen but the tar ball is getting created. I freebsd 8 is the OS by the way. Following is the script.

#!/bin/bash

BACKUPDIR=/usr/local/
CONTENT1=/usr/local/etc/squid
BACKUPFILE=squid.backup.`date +%F`

tar -czvf $BACKUPDIR/$BACKUPFILE $CONTENT1

cd $BACKUPDIR
curl -v -T squid.back* ftp://sqbackupass123@192.168.0.99/

#END

only the curl part doesnt work. Again note when I run this on the shell the whole thing work as a charm. I guess this has something to do with the crontab. Can someone help out please? Oh this is how my crontab entry looks and the job is run by root.
10 11 * * * sh /usr/local/sqbkup.sh

Thank you very much.
 
Old 05-11-2010, 08:14 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Have you tried with the full path of the curl command? I don't know exactly on freeBSD, but cron has a very limited environment and the PATH is usually /bin:/usr/bin. If curl is installed somewhere else, maybe cron is not able to find the executable. If this the issue, specifying the full path of curl should do the trick.

Moreover, since the standard output and the standard error are not redirected to a file, most likely the crontab's owner has received a mail with all the messages coming from the cron job (especially considered the fact that tar and curl use the verbose option in your script).
 
Old 05-11-2010, 01:35 PM   #3
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
There are multiple problems. There is no /bin/bash (unless you've installed the port -- and even then it won't be in the path you specified). You're explicitly running it through /bin/sh in your crontab anyway, so you might as well correct that in your script.

Also, as colucix mentioned, cron's PATH does not include /usr/local/bin, which is where the curl binary lives. Either use FQ binary names, or build your PATH appropriately at the beginning of your script. (I prefer to do the latter.)
 
Old 05-12-2010, 04:40 AM   #4
Vimuth
Member
 
Registered: Sep 2009
Posts: 59

Original Poster
Rep: Reputation: 15
Smile

Dear Good gentleman
Thank you very much for your advice gentlemen. When I specified the full path of the curl utility things started to fall in place. The amended of my script now looks like the following.

/usr/local/bin/curl -v -T squid.back*

Again thank you very much.
Edit/Delete Message
 
  


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
crontab for diffrent user than root doesnt work dlugasx Linux - Server 3 07-10-2009 07:38 AM
Why doesnt my USB mouse doesnt work? barkha Linux - Hardware 2 08-16-2005 12:31 PM
Crontab -e doesnt run my script ! c0nsur Linux - General 4 08-04-2005 12:21 AM
crontab doesnt works with all jobs. pxes351 Linux - Newbie 2 05-10-2004 02:11 AM
crontab on freebsd 5.1 rafalek *BSD 4 04-05-2004 11:14 PM

LinuxQuestions.org > Forums > Other *NIX Forums > *BSD

All times are GMT -5. The time now is 09:41 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
Open Source Consulting | Domain Registration