Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: crontab not redirecting complete output to file

  1. #1
    Join Date
    Mar 2014
    Beans
    8

    crontab not redirecting complete output to file

    i am new to Linux Ubuntu I had a shell script which has to redirect 18000 lines output to file. output is truncating at 2006th line. is there any buffer settings for crontab
    my shell script is below rcap.sh
    Code:
     #!/bin/bash
    /usr/local/bin/sshpass -p "xxxxxxxxx" ssh -2oStrictHostKeyChecking=no xxxxxxxx@10.0.0.1 "sh ip route bgp"
    | awk '{print $2 }' > /home/ubuntuusr/scripts/mplsupid.txt
    and my crontab entry is
    Code:
    * * * * * /home/ubuntuusr/scripts/rcap.sh
    when I run manually I am getting full 18000+ lines output to mplsupid.txt

    when I run with crontab only 2006 lines only

  2. #2
    Join Date
    Sep 2008
    Location
    Chicago
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: crontab not redirecting complete output to file

    This suggestion is a bit "out there," but you might bring up the file in an editor and examine line 2007 to see if it is malformed in some way. Buffer overrun may also be an issue.
    In working with *nix...There be dragons. Newcomers: I recommend reading Linux is Not Windows (http://linux.oneandoneis2.org/LNW.htm) and The Linux Command Line (http://www.linuxcommand.org/tlcl.php) before beginning your quest for a better OS.

  3. #3
    Join Date
    Mar 2014
    Beans
    8

    Re: crontab not redirecting complete output to file

    manually I am getting full output with 18000 lines.

  4. #4
    Join Date
    Mar 2014
    Beans
    8

    Re: crontab not redirecting complete output to file

    whitesmith I am getting full output when I run same script manually

  5. #5
    Join Date
    Mar 2014
    Beans
    8

    Re: crontab not redirecting complete output to file

    I am getting full output when I run same script manually

  6. #6
    Join Date
    Aug 2011
    Location
    52.5° N 6.4° E
    Beans
    6,806
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: crontab not redirecting complete output to file

    How long does the script need for running? Cron starts the script every minute, I imagine things go wrong when the new instance truncates the file and starts writing it from the beginning before the previous instance has finished.

  7. #7
    Join Date
    Mar 2014
    Beans
    8

    Re: crontab not redirecting complete output to file

    when I run manually script is running for 4-8 sec only and I test for every 30 minutes 30 * * * * still I am getting same truncating at 2006th line

  8. #8
    Join Date
    Sep 2010
    Beans
    898

    Re: crontab not redirecting complete output to file

    To eliminate the possibility that the file is getting overwritten, you could timestamp the filename:
    Code:
    /home/ubuntuusr/scripts/mplsupid_`date +%Y%m%d_%H%M%S`.txt
    To view any diagnostic messages, add to the end of the command:
    Code:
     2>&1

  9. #9
    Join Date
    Mar 2014
    Beans
    8

    Re: crontab not redirecting complete output to file

    I had added log file & I changed as /home/ubuntuusr/scripts/mplsupid_`date +%Y%m%d_%H%M%S`.txt
    &

    * * * * * /home/ubuntuusr/scripts/rcap.sh >> /home/ubuntuusr/scripts/script.log 2>&1

    no error displaying in script.log

  10. #10

    Re: crontab not redirecting complete output to file

    Never, ever use passwords in shell scripts. EVER!
    Windows assumes the user is an idiot.
    Linux demands proof.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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