LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   find all the current log file with date and copy to a specific folder. (https://www.linuxquestions.org/questions/linux-newbie-8/find-all-the-current-log-file-with-date-and-copy-to-a-specific-folder-4175559510/)

boby.kumar 11-21-2015 09:39 AM

find all the current log file with date and copy to a specific folder.
 
Hi,
I want to fetch all the current updated files in a directory and copy them to another without using the name of each files.
PHP Code:

userls -head -n1 

This command only gives a file which is last updated. want to all the files with current date and time and copy them.

PHP Code:

userls -lrt
total 60
-rw-------   1 root     sys            0 Mar 17  2009 authlog
drwxr
-xr-x   2 root     sys          512 Oct  9  2009 pool
drwxr
-xr-x   2 root     sys          512 Oct  9  2009 swupas
-rw-r--r--   1 root     other         27 Oct  9  2009 brlog
-rw-r--r--   1 root     root        2192 Oct  9  2009 postrun.log
drwxr
-xr-x   3 root     sys          512 Oct 12  2009 webconsole
-rw-r--r--   1 root     other       1363 Dec 20  2011 sysidconfig.log
-rw-------   1 root     root       20262 Jun 17 16:11 in.iked.log
-rw-r--r--   1 root     root          23 Jun 17 16:11 snmpd.log 

for eg. last two files which is updated on the same time.

Can any one have the command to do this in shell ?

Thanks

TB0ne 11-21-2015 10:36 AM

Wow, this sounds familiar:http://www.linuxquestions.org/questi...pt-4175556776/

Again,post what you have tried.

normanlinux 11-21-2015 02:14 PM

Try looking at the options to the find command

allend 11-21-2015 06:03 PM

The 'touch' command using the '-t' option can create a file with an arbitrary date and time stamp.
The 'find' command in conjunction with the '-newer' option can make use of such a file.

berndbausch 11-22-2015 12:57 AM

Quote:

Originally Posted by boby.kumar (Post 5453233)
Hi,
I want to fetch all the current updated files in a directory and copy them to another without using the name of each files.
PHP Code:

userls -head -n1 

This command only gives a file which is last updated. want to all the files with current date and time and copy them.

PHP Code:

userls -lrt
total 60
-rw-------   1 root     sys            0 Mar 17  2009 authlog
drwxr
-xr-x   2 root     sys          512 Oct  9  2009 pool
drwxr
-xr-x   2 root     sys          512 Oct  9  2009 swupas
-rw-r--r--   1 root     other         27 Oct  9  2009 brlog
-rw-r--r--   1 root     root        2192 Oct  9  2009 postrun.log
drwxr
-xr-x   3 root     sys          512 Oct 12  2009 webconsole
-rw-r--r--   1 root     other       1363 Dec 20  2011 sysidconfig.log
-rw-------   1 root     root       20262 Jun 17 16:11 in.iked.log
-rw-r--r--   1 root     root          23 Jun 17 16:11 snmpd.log 

for eg. last two files which is updated on the same time.

Can any one have the command to do this in shell ?

Thanks

What do you mean by "current"? June 17 is not exactly the current date. Do you mean:
  • The files that were updated today
  • The files that were updated in the current minute
  • Something else?

Habitual 11-22-2015 06:52 AM

Quote:

Originally Posted by boby.kumar (Post 5453233)
Hi,
I want to fetch all the current updated files in a directory and copy them to another without using the name of each files.

You could do this with syslog.
This way, the syslog-server host would always have the 'latest' copy of any file you choose. In fact, it updates the remote copy in near real-time.

Ask if you want more info on the specifics.
But here's a startup set for 2 files (apache2 access and error).
There's no reason it can't be done for files in /var/log also.


All times are GMT -5. The time now is 05:58 PM.