[SOLVED] Move files to dev null

Discussion in 'Linux' started by BJ0RN, Mar 18, 2017.

  1. BJ0RN

    BJ0RN MDL HTTP-uploader

    Dec 6, 2013
    334
    21,791
    10
    #1 BJ0RN, Mar 18, 2017
    Last edited: Mar 23, 2017
    Hello MDL

    Todays question is: How do I move specific files inside a folder to dev null?

    Say I gave file things.log, things2.log and so on and I have things.txt, things2.txt and so on, is there a command to move all *.logs files and not delete the *.txt ones??

    Im too lazy to look for the answer myself :beee: and I dont know what to search for. :D :D

    Best, Bjørn
     
  2. TT_ZX

    TT_ZX MDL Novice

    Aug 27, 2010
    33
    25
    0
    rm <pathtofolder>/*.logs . I usually like to do, ls <pathtofolder>/*.logs , to list what would be deleted first just to be sure I'm not deleting the wrong files.
     
  3. BJ0RN

    BJ0RN MDL HTTP-uploader

    Dec 6, 2013
    334
    21,791
    10
    Well this would solve it if I was to remove the files, but I need to do it with "live" files. I need it so they are gone, but still there. They are active log files. :D
     
  4. JohnHenry

    JohnHenry MDL Novice

    Dec 28, 2016
    12
    5
    0
    I'd say my understand is very limited, but /dev/null is a pseudo-device that acts as an input and output stream of null. What you're trying to do doesn't make any sense. You can pipe log output to /dev/null and all of the output will be discarded. You can use dd to write /dev/null to the files you want to null and the contents will disappear. You could use rm to remove the files, or shred to overwrite their data on the disk. But you are not going to get very far in linux if you're just expecting to be spoonfed answers and are, by your own admission, unwilling to solve problems and expand your understanding by yourself.
     
  5. BJ0RN

    BJ0RN MDL HTTP-uploader

    Dec 6, 2013
    334
    21,791
    10
    What Im trying to do is, I run a program that creates .log files in a set folder each time it runs. The files have different filenames each time. I want them to be "deleted" in the term that they do not contain data but they are still there. If I just do RM then the file will be gone and the program will crash. I want them to be there, but not grow in size... :g:
    Also @John, the ending was... For fun. ;) :p
     
  6. Michaela Joy

    Michaela Joy MDL Crazy Lady

    Jul 26, 2012
    4,071
    4,651
    150
    @bjorn: You want to set the file length to zero bytes, but you want the actual file to stay around.

    Do you have the source code to this program? Maybe there's a way to turn off log file generation for that specific program.

    Just a late night thought...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. BJ0RN

    BJ0RN MDL HTTP-uploader

    Dec 6, 2013
    334
    21,791
    10
    yeah, its nodejs, "forever" program. :p

    Probs should have said that. :D


     
  8. JohnHenry

    JohnHenry MDL Novice

    Dec 28, 2016
    12
    5
    0
    If the program doesn't have a way to disable it's logging, remove each log file, then create a symbolic link from the old path of the logfile to /dev/null.
     
  9. BJ0RN

    BJ0RN MDL HTTP-uploader

    Dec 6, 2013
    334
    21,791
    10
    I thought about that, it will not work because the program makes a new log file almost every time it runs, with a random name. :weep:

     
  10. TT_ZX

    TT_ZX MDL Novice

    Aug 27, 2010
    33
    25
    0
    Maybe you can use logrotate to do what you want.
     
  11. BJ0RN

    BJ0RN MDL HTTP-uploader

    Dec 6, 2013
    334
    21,791
    10
    #11 BJ0RN, Mar 23, 2017
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Thanks for suggestion. Looked into that, but I found an easier way. Seems like I havent read the documentation well enough for the program.
    Code:
    forever start -a -l /dev/null script.js
    will do what I want. Also it has no problems assigning multiple files to it. Silly me. :D

    Thanks folks. :hug2:

     
  12. Michaela Joy

    Michaela Joy MDL Crazy Lady

    Jul 26, 2012
    4,071
    4,651
    150
    That's the great thing about open source. If it's documented poorly, you can always look at the source code and see how it works.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...