Skip to content
Advertisement

How to hold or copy files at run time in CENTOS 7

I have a tool that converts COBOL files to C++.

When I run the command, it generates the.cpp file from the.cbl file but deletes it at run time.

It is not holding the files or not saving the file in the designated folder, despite the fact that I can see that the.cpp file is created but destroyed within seconds.

I’m using CentOS 7.

Can somebody tell me how to keep that.cpp file or copy it at runtime to a different location?

Advertisement

Answer

You can use inotifywait to monitor the directory, where the CPP files are created. Whenever a CREATE event occurs, you can link the file into a backup directory.

#! /bin/bash

test -d backup || mkdir backup
inotifywait --monitor --event CREATE --format %f . |
  while read file; do
    ln "$file" backup/"$file"
  done
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement