Navigation

    Netgate Discussion Forum
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search

    Time and date stamps in cron?

    General pfSense Questions
    2
    5
    1552
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      clarknova last edited by

      I'm trying to create a cron job to periodically log the output of 'netstat -m' with a timestamp, but I'm not sure how to create the timestamp. So I'm thinking of a command something like this

      
      echo "$date $time `netstat -m` >> /var/log/netstat-m.log
      
      

      but I don't know how to produce current values for $date and $time. Help?

      Also, some tips on formatting the output would be good, like how to insert a line break after the output. Thanks.

      1 Reply Last reply Reply Quote 0
      • jimp
        jimp Rebel Alliance Developer Netgate last edited by

        Make sure you use the full path to every command in a cron entry, and no need to involve echo:

        /bin/date >> /var/log/netstat-m.log; /usr/bin/netstat -m >> /var/log/netstat-m.log
        
        1 Reply Last reply Reply Quote 0
        • C
          clarknova last edited by

          Perfect. Thanks.

          1 Reply Last reply Reply Quote 0
          • C
            clarknova last edited by

            One more thing, does that directory survive reboots?

            1 Reply Last reply Reply Quote 0
            • jimp
              jimp Rebel Alliance Developer Netgate last edited by

              On a full install, yes. On nanobsd, no.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post

              Products

              • Platform Overview
              • TNSR
              • pfSense Plus
              • Appliances

              Services

              • Training
              • Professional Services

              Support

              • Subscription Plans
              • Contact Support
              • Product Lifecycle
              • Documentation

              News

              • Media Coverage
              • Press
              • Events

              Resources

              • Blog
              • FAQ
              • Find a Partner
              • Resource Library
              • Security Information

              Company

              • About Us
              • Careers
              • Partners
              • Contact Us
              • Legal
              Our Mission

              We provide leading-edge network security at a fair price - regardless of organizational size or network sophistication. We believe that an open-source security model offers disruptive pricing along with the agility required to quickly address emerging threats.

              Subscribe to our Newsletter

              Product information, software announcements, and special offers. See our newsletter archive to sign up for future newsletters and to read past announcements.

              © 2021 Rubicon Communications, LLC | Privacy Policy