How to empty file every n hours bash


Results 1 to 2 of 2

Thread: How to empty file every n hours bash

  1. #1
    Join Date
    Apr 2014
    Posts
    34

    How to empty file every n hours bash

    Hello,

    im running an bash script every 10 minutes
    and if possible i want to add an command into that script so certain file is emptied every 5 hours.

    That file i want to empty is being frequently updated with new data, every 10 minutes.

    file details: (update happening every 10 minutes)
    Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
    Access: 2015-06-09 10:20:46.715955503 -0400
    Modify: 2015-06-09 10:20:46.714955570 -0400
    Change: 2015-06-09 10:20:46.714955570 -0400

    thx

  2. #2
    Join Date
    Jun 2015
    Posts
    1
    i just tested, you can do this:
    Code:
    : > my-file.log
    test it:
    Code:
    [ -s my-file.log ] && echo Not Empty || Empty

Posting Permissions

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