Results 1 to 4 of 4

Thread: curl doesnt work in crontab

  1. #1
    Junior Member
    Join Date
    Sep 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default curl doesnt work in crontab

    Dear All,
    Following is a simple shell script that 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. 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*

    #END

    only the curl part doesnt work. 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.

  2. #2
    Contributors jaysunn's Avatar
    Join Date
    Apr 2009
    Location
    NYC - USA
    Posts
    1,027
    Thanks
    165
    Thanked 154 Times in 133 Posts
    Rep Power
    24

    Default

    Hello,
    Try adding the full path the curl executable. I highlighted it in red. Also use the full path for the variable also in red.

    Code:
    #!/bin/bash
    
    BACKUPDIR=/usr/local/
    CONTENT1=/usr/local/etc/squid
    BACKUPFILE=squid.backup.`date +%F`
    
    tar -czvf $BACKUPDIR/$BACKUPFILE $CONTENT1 
    
    
    /usr/bin/curl -v -T $BACKUPDIR/squid.back* 
    
    #END
    EDIT:
    Also curl is used for transferring URLS, I don't see any FTP parts happening in your script. You can probably use cp command instead of curl.

    HTH,
    jaysunn
    Last edited by jaysunn; 11th May 2010 at 09:24 PM. Reason: Added Curl vs CP

  3. #3
    Junior Member
    Join Date
    Sep 2009
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Dear Mr Jaysunn,

    Thank you very much for your advice sir. When I specified the full path of the curl utility things started to fall in place. The ammended directive now looks like the following.

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

    Again thank you very much.

  4. #4
    Contributors jaysunn's Avatar
    Join Date
    Apr 2009
    Location
    NYC - USA
    Posts
    1,027
    Thanks
    165
    Thanked 154 Times in 133 Posts
    Rep Power
    24

    Default [solved]

    Great News,
    Glad we got this sorted out.

    Jaysunn

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Crontab on Mac OSX 10.6.2
    By GlobalNerds in forum Mac OS X
    Replies: 1
    Last Post: 8th March 2010, 06:20 PM
  2. How does apt-get install work?
    By eawedat in forum Ubuntu / Debian
    Replies: 3
    Last Post: 6th March 2010, 06:29 PM
  3. Diff b/w /etc/crontab and /usr/bin/crontab
    By Prachi in forum Shell scripting
    Replies: 6
    Last Post: 4th February 2009, 08:29 AM
  4. Curl and iksemel libraries for Redhat EL4
    By teekay3001 in forum Linux software
    Replies: 4
    Last Post: 21st June 2007, 03:30 PM
  5. will this work?
    By mudfish in forum Shell scripting
    Replies: 0
    Last Post: 28th March 2007, 12:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •