I am using glog in my app that is deployed in a docker container and it has created hundreds of tiny files and I am wondering why and how to stop it. Here is a small sample of my directory listing.
-rw-r--r--. 1 urbncat urbncat 20 Jun 27 18:40 InventoryProcessor.32c423b6e305.urbncat.log.INFO.20170626-134018.246-1498528861.gz-1498536061.gz-1498546861.gz-1498550462.gz-1498582862.gz-1498590064.gz-1498608095.gz
-rw-r--r--. 1 urbncat urbncat 20 Jun 27 20:14 InventoryProcessor.32c423b6e305.urbncat.log.INFO.20170626-134018.246-1498528861.gz-1498536061.gz-1498546861.gz-1498550462.gz-1498582862.gz-1498590064.gz-1498611709.gz
-rw-r--r--. 1 urbncat urbncat 0 Jun 27 23:34 InventoryProcessor.32c423b6e305.urbncat.log.INFO.20170626-134018.246-1498528861.gz-1498536061.gz-1498546861.gz-1498550462.gz-1498586462.gz-1498593665.gz
-rw-r--r--. 1 urbncat urbncat 20 Jun 27 18:40 InventoryProcessor.32c423b6e305.urbncat.log.INFO.20170626-134018.246-1498528861.gz-1498536061.gz-1498546861.gz-1498550462.gz-1498586462.gz-1498593665.gz-1498604479.gz
-rw-r--r--. 1 urbncat urbncat 20 Jun 27 18:40 InventoryProcessor.32c423b6e305.urbncat.log.INFO.20170626-134018.246-1498528861.gz-1498536061.gz-1498546861.gz-1498550462.gz-1498586462.gz-1498593665.gz-1498608095.gz
-rw-r--r--. 1 urbncat urbncat 20 Jun 27 20:14 InventoryProcessor.32c423b6e305.urbncat.log.INFO.20170626-134018.246-1498528861.gz-1498536061.gz-1498546861.gz-1498550462.gz-1498586462.gz-1498593665.gz-1498611709.gz
-rw-r--r--. 1 urbncat urbncat 0 Jun 27 23:34 InventoryProcessor.32c423b6e305.urbncat.log.INFO.20170626-134018.246-1498528861.gz-1498536061.gz-1498546861.gz-1498550462.gz-1498590064.gz-1498597268.gz
-rw-r--r--. 1 urbncat urbncat 54 Jun 27 14:04 InventoryProcessor.32c423b6e305.urbncat.log.INFO.20170626-134018.246-1498528861.gz-1498536061.gz-1498546861.gz-1498550462.gz-1498590064.gz-1498597268.gz-1498604479.gz
-rw-r--r--. 1 urbncat urbncat 20 Jun 27 14:04 InventoryProcessor.32c423b6e305.urbncat.log.INFO.20170626-134018.246-1498528861.gz-1498536061.gz-1498546861.gz-1498550462.gz-1498590064.gz-1498597268.gz-1498608095.gz
-rw-r--r--. 1 urbncat urbncat 20 Jun 27 20:14 InventoryProcessor.32c423b6e305.urbncat.log.INFO.20170626-134018.246-1498528861.gz-1498536061.gz-1498546861.gz-1498550462.gz-1498590064.gz-1498597268.gz-1498611709.gz
Related
I have a total of 31 directories. Every directory has a random name.
❯ ls -al
total 32
drwxr-xr-x 34 shinokada staff 1088 Dec 28 17:16 .
drwxr-xr-x 32 shinokada staff 1024 Dec 28 17:12 ..
-rw-r--r--# 1 shinokada staff 14340 Dec 28 17:16 .DS_Store
drwxr-xr-x 5 shinokada staff 160 Dec 28 17:10 05618066
drwxr-xr-x 5 shinokada staff 160 Dec 28 17:08 0fef2d20
drwxr-xr-x 5 shinokada staff 160 Dec 28 17:09 11ff096d
drwxr-xr-x 5 shinokada staff 160 Dec 28 17:09 1651ff1f
drwxr-xr-x 5 shinokada staff 160 Dec 28 17:09 2123b256
... and more
Now I'd like to rename them sample1 sample2 sample3 ...sample31.
How can I do it on a terminal(bash/zsh)?
Is there a quick way to do it rather than rename one by one?
This should do:
num=1; for dir in */ ; do mv "${dir}" "sample$num" ; ((num++)); done
I assume you don't want to rename the files, only directories inside your current working directory.
Problem
Ubuntu 18.04. The logs for some files not sending. For example I have has 16 log files on 2020-06-23. But only #5 & #8 got collected into data.json. Others are not found in data.json
Here's a script I use to found files on disk but not in data.json.
sudo python -c '
import json; import os;
raw = os.listdir("/path/to/my/logdir")
f = open("/var/lib/filebeat/registry/filebeat/data.json", "r")
data=json.load(f)
harvested=[d["source"].split("/")[-1] for d in data]
substraction=[x for x in raw if not x in harvested]
print("\n".join(substraction))
'
The script result, there's just a lot:
app-2020-06-21.20.log
app-2020-06-21.25.log
app-2020-06-23.11.log
app-2020-06-22.1.log
app-2020-06-22.48.log
app-2020-06-21.41.log
app-2020-06-23.15.log
...
And there are only 2 types of logs End of file reached and Non-zero metrics in the last 30s :
Jun 23 12:23:12 filebeat[32738]: 2020-06-23T12:23:12.223Z DEBUG [harvester] log/log.go:107 End of file reached: /path/to/my/logdir/app-2020-06-21.43.log; Backoff now.
Jun 23 12:23:12 filebeat[32738]: 2020-06-23T12:23:12.344Z DEBUG [harvester] log/log.go:107 End of file reached: /path/to/my/logdir/app-2020-06-22.9.log; Backoff now.
Jun 23 12:23:12 filebeat[32738]: 2020-06-23T12:23:12.364Z DEBUG [harvester] log/log.go:107 End of file reached: /path/to/my/logdir/app-2020-06-21.34.log; Backoff now.
Jun 23 12:23:12 filebeat[32738]: 2020-06-23T12:23:12.444Z DEBUG [harvester] log/log.go:107 End of file reached: /path/to/my/logdir/app-2020-06-23.5.log; Backoff now.
Jun 23 12:23:15 filebeat[32738]: 2020-06-23T12:23:15.144Z INFO [monitoring] log/log.go:145 Non-zero metrics in the last 30s {"monitoring": {"metrics": {"beat":{"cpu":{"system":{"ticks":350,"time":{"ms":10}},"total":{"ticks":1710,"ti
Jun 23 12:23:45 filebeat[32738]: 2020-06-23T12:23:45.144Z INFO [monitoring] log/log.go:145 Non-zero metrics in the last 30s {"monitoring": {"metrics": {"beat":{"cpu":{"system":{"ticks":350,"time":{"ms":9}},"total":{"ticks":1720,"tim
Jun 23 12:24:15 filebeat[32738]: 2020-06-23T12:24:15.144Z INFO [monitoring] log/log.go:145 Non-zero metrics in the last 30s {"monitoring": {"metrics": {"beat":{"cpu":{"system":{"ticks":360,"time":{"ms":6}},"total":{"ticks":1740,"tim
Jun 23 12:24:45 filebeat[32738]: 2020-06-23T12:24:45.144Z
Details
Filebeat config
output:
logstash:
enabled: true
hosts:
- x.x.x.x:5044
filebeat:
inputs:
-
paths:
- "/path/to/log/dir/*"
document_type: myapp
multiline.pattern: '^[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}'
multiline.negate: true
multiline.match: after
clean_removed: true
close_removed: true
logging.level: debug
name: "myapp"
tags: ["tag1", "tag2"]
Disk
Here's is the usage. I guess disk is fine
Filesystem Size Used Avail Use% Mounted on
... 2.0G 0 2.0G 0% /dev
... 395M 820K 394M 1% /run
... 30G 12G 18G 41% /
Here's the inode checking result. You can see that there's no duplicated inode in 06-23 logs.
ls -il * | grep 06-23
768289 -rw-r--r-- 1 root root 10485996 Jun 23 00:33 app-2020-06-23.0.log
768372 -rw-r--r-- 1 root root 10486447 Jun 23 01:02 app-2020-06-23.1.log
768292 -rw-r--r-- 1 root root 10485819 Jun 23 05:36 app-2020-06-23.10.log
800654 -rw-r--r-- 1 root root 10499153 Jun 23 05:59 app-2020-06-23.11.log
794052 -rw-r--r-- 1 root root 10486575 Jun 23 06:32 app-2020-06-23.12.log
768487 -rw-r--r-- 1 root root 10492683 Jun 23 06:59 app-2020-06-23.13.log
800633 -rw-r--r-- 1 root root 10490445 Jun 23 07:27 app-2020-06-23.14.log
794067 -rw-r--r-- 1 root root 10500849 Jun 23 07:55 app-2020-06-23.15.log
788191 -rw-r--r-- 1 root root 10489159 Jun 23 08:28 app-2020-06-23.16.log
788410 -rw-r--r-- 1 root root 10486744 Jun 23 09:30 app-2020-06-23.17.log
800624 -rw-r--r-- 1 root root 10486794 Jun 23 10:00 app-2020-06-23.18.log
794048 -rw-r--r-- 1 root root 10490002 Jun 23 10:39 app-2020-06-23.19.log
768461 -rw-r--r-- 1 root root 10486161 Jun 23 01:36 app-2020-06-23.2.log
794051 -rw-r--r-- 1 root root 10488204 Jun 23 11:12 app-2020-06-23.20.log
794081 -rw-r--r-- 1 root root 10487146 Jun 23 11:46 app-2020-06-23.21.log
794071 -rw-r--r-- 1 root root 10492866 Jun 23 12:16 app-2020-06-23.22.log
787673 -rw-r--r-- 1 root root 10490849 Jun 23 12:51 app-2020-06-23.23.log
787698 -rw-r--r-- 1 root root 3491076 Jun 23 13:00 app-2020-06-23.24.log
768478 -rw-r--r-- 1 root root 10486306 Jun 23 02:08 app-2020-06-23.3.log
768507 -rw-r--r-- 1 root root 10486690 Jun 23 02:34 app-2020-06-23.4.log
800620 -rw-r--r-- 1 root root 10496353 Jun 23 03:00 app-2020-06-23.5.log
800623 -rw-r--r-- 1 root root 10503668 Jun 23 03:36 app-2020-06-23.6.log
768521 -rw-r--r-- 1 root root 10520722 Jun 23 04:05 app-2020-06-23.7.log
774652 -rw-r--r-- 1 root root 10487379 Jun 23 04:38 app-2020-06-23.8.log
784704 -rw-r--r-- 1 root root 10553972 Jun 23 05:05 app-2020-06-23.9.log
[root#amp logs]# ls -l
total 0
-rw-r--r-- 1 root root 0 Nov 23 17:51 lb-quarzcenter.log
-rw-r--r-- 1 root root 0 Feb 27 17:26 lb-quarzcenter.log.2019-02-01
-rw-r--r-- 1 root root 0 Feb 27 17:26 lb-quarzcenter.log.2019-02-02
-rw-r--r-- 1 root root 0 Feb 27 17:26 lb-quarzcenter.log.2019-02-03
-rw-r--r-- 1 root root 0 Feb 27 17:26 lb-quarzcenter.log.2019-02-04
-rw-r--r-- 1 root root 0 Feb 27 17:26 lb-quarzcenter.log.2019-02-05
-rw-r--r-- 1 root root 0 Feb 27 17:26 lb-quarzcenter.log.2019-02-06
-rw-r--r-- 1 root root 0 Feb 27 17:26 lb-quarzcenter.log.2019-02-07
-rw-r--r-- 1 root root 0 Feb 27 17:26 lb-quarzcenter.log.2019-02-08
-rw-r--r-- 1 root root 0 Feb 27 17:26 lb-quarzcenter.log.2019-02-10
-rw-r--r-- 1 root root 0 Feb 27 17:26 lb-quarzcenter.log.2019-02-11
-rw-r--r-- 1 root root 0 Feb 27 17:26 lb-quarzcenter.log.2019-02-12
-rw-r--r-- 1 root root 0 Feb 27 17:26 lb-quarzcenter.log.2019-02-13
-rw-r--r-- 1 root root 0 Feb 27 17:26 lb-quarzcenter.log.2019-02-14
-rw-r--r-- 1 root root 0 Nov 23 17:51 lb-quarzcenter.log.2019-02-15
-rw-r--r-- 1 root root 0 Feb 27 17:26 lb-quarzcenter.log.2019-02-09
How do I match a string with year-month-date and delete 10 days ago file according to lb-quarzcenter.log.*?
now=$(date +%s) # express current time as seconds since 1970-01-01
(( ten_days_ago = now - 60*60*24*10 )) # subtract 864000 seconds (10 days) from that
date_minus_ten=$(date +%F --date="#$ten_days_ago") # express that number as a YYYY-MM-DD
for filename in lb-quartzcenter.log.* ; do # loop over all matching files
filedate="${filename/lb-quartzcenter.log./}" # remove the filename part before the timestamp
if [[ $filedate < $date_minus_ten ]] ; then # if filename remainder is lexicographically lower...
rm -f "$filename" # ... remove the file
fi
done
I am looking for a command which can show the list of files which are older than 1 day and a command which can delete those files.
Here is the command I have:
sudo find -type f -name "*.tmp" -mtime +1 -exec ls -ltrh {} \;
This command is giving me the list of files which are older than 2 days. But I want to get the list of files which are more than 24Hrs old.
Similarly, I have below command which deletes the files:
sudo find -type f -name "*.tmp" -mtime +1 -delete
Again same issue, it deletes only those files which are 2 days old.
Can you help me with the correct command to use.
**Update : **
This is the list which I got if I do ls -ltr
-rw------- 1 user user 56344 Jun 18 03:22 4852594605084969096.tmp
-rw------- 1 user user 62420 Jun 18 03:52 8128596406378306564.tmp
-rw------- 1 user user 45108 Jun 18 05:14 9221373979761847380.tmp
-rw------- 1 user user 52092 Jun 18 05:38 8803375736497642014.tmp
-rw------- 1 user user 46076 Jun 18 05:55 2597624169466947823.tmp
-rw------- 1 user user 45108 Jun 18 06:10 7331064027553067163.tmp
-rw------- 1 user user 57600 Jun 18 06:53 571617644221476695.tmp
-rw------- 1 user user 46076 Jun 18 06:53 3250632105294480811.tmp
-rw------- 1 user user 46076 Jun 18 06:53 3049416494164364083.tmp
-rw------- 1 user user 56344 Jun 18 07:28 3800708410202563331.tmp
-rw------- 1 user user 45108 Jun 18 07:28 8459614580010423232.tmp
-rw------- 1 user user 43520 Jun 18 07:57 8661904436966583049.tmp
-rw------- 1 user user 46076 Jun 18 07:57 1204891285897472382.tmp
-rw------- 1 user user 81900 Jun 18 09:32 8465358150249612844.tmp
-rw------- 1 user user 124432 Jun 18 09:32 7187243412111611681.tmp
-rw------- 1 user user 56436 Jun 18 09:51 8372171566419231034.tmp
-rw------- 1 user user 42904 Jun 18 09:51 667863893329482278.tmp
-rw------- 1 user user 41972 Jun 18 10:11 3847591475306960147.tmp
-rw------- 1 user user 116872 Jun 18 10:11 7966362913792512054.tmp
-rw------- 1 user user 45108 Jun 18 10:11 8439035344531042431.tmp
-rw------- 1 user user 185560 Jun 18 10:11 8474346694096813378.tmp
-rw------- 1 user user 46076 Jun 18 10:11 4760470706645148372.tmp
-rw------- 1 user user 41972 Jun 18 10:11 9157761570806548970.tmp
-rw------- 1 user user 42904 Jun 18 10:12 8915926699291849585.tmp
-rw------- 1 user user 41972 Jun 18 10:22 4483378368608075076.tmp
-rw------- 1 user user 46076 Jun 18 10:22 8039354996724735242.tmp
-rw------- 1 user user 46076 Jun 18 10:22 1441427612150519563.tmp
-rw------- 1 user user 46076 Jun 18 13:39 3895289049566214606.tmp
-rw------- 1 user user 46076 Jun 18 13:41 4523819359899311681.tmp
-rw------- 1 user user 59608 Jun 18 14:28 5171792312670553667.tmp
-rw------- 1 user user 41972 Jun 18 16:07 1381867850547954997.tmp
-rw------- 1 user user 46076 Jun 18 16:08 2377385254288601418.tmp
-rw------- 1 user user 46076 Jun 18 16:08 2757855781341192620.tmp
-rw------- 1 user user 46076 Jun 18 16:08 990402164110920641.tmp
-rw------- 1 user user 88980 Jun 18 17:02 3519429446055316602.tmp
-rw------- 1 user user 46076 Jun 18 18:34 2718504484399041994.tmp
-rw------- 1 user user 52588 Jun 18 20:40 8282149999256755040.tmp
-rw------- 1 user user 45108 Jun 18 20:40 2535213203951007401.tmp
-rw------- 1 user user 62804 Jun 18 20:41 3344181299125676547.tmp
-rw------- 1 user user 46076 Jun 18 20:56 5704898344921554440.tmp
-rw------- 1 user user 57600 Jun 18 21:04 6910781806107437056.tmp
-rw------- 1 user user 57600 Jun 18 21:05 8996587449350363530.tmp
-rw------- 1 user user 57600 Jun 18 21:05 2201114289500171076.tmp
-rw------- 1 user user 171212 Jun 18 21:43 568113257671337808.tmp
-rw------- 1 user user 46076 Jun 19 02:22 4686252438135803799.tmp
-rw------- 1 user user 46076 Jun 19 02:23 1024337710253657481.tmp
-rw------- 1 user user 46076 Jun 19 02:23 8138681836575745204.tmp
-rw------- 1 user user 46076 Jun 19 02:23 4551895045706757158.tmp
-rw------- 1 user user 72880 Jun 19 02:58 6720139662475805522.tmp
-rw------- 1 user user 138036 Jun 19 03:39 4261193719990867277.tmp
-rw------- 1 user user 43520 Jun 19 04:30 2189638076744384268.tmp
-rw------- 1 user user 46076 Jun 19 04:30 9069524378589378948.tmp
-rw------- 1 user user 46076 Jun 19 06:21 4197944256637931725.tmp
-rw------- 1 user user 41972 Jun 19 07:01 4881839192080059356.tmp
-rw------- 1 user user 41972 Jun 19 07:29 7939325415825814975.tmp
-rw------- 1 user user 52092 Jun 19 08:02 334987770024624782.tmp
-rw------- 1 user user 38504 Jun 19 09:19 2006993025338095576.tmp
-rw------- 1 user user 43520 Jun 19 09:41 7349787809048549539.tmp
-rw------- 1 user user 42904 Jun 19 09:45 1393091432117053268.tmp
-rw------- 1 user user 52588 Jun 19 09:45 6110897423492319793.tmp
-rw------- 1 user user 62804 Jun 19 09:45 9143197155997936730.tmp
-rw------- 1 user user 88980 Jun 19 10:47 2758611773267584579.tmp
-rw------- 1 user user 88980 Jun 19 10:47 8190296254180009992.tmp
-rw------- 1 user user 45108 Jun 19 13:06 5668356474649690853.tmp
-rw------- 1 user user 46076 Jun 19 13:06 8831342235645870908.tmp
-rw------- 1 user user 52092 Jun 19 13:07 3760436936603717823.tmp
-rw------- 1 user user 46020 Jun 19 13:43 5381449090462674458.tmp
-rw------- 1 user user 45108 Jun 19 13:51 5714193329079454521.tmp
-rw------- 1 user user 62420 Jun 19 14:08 1861226554558152474.tmp
-rw------- 1 user user 45108 Jun 19 14:09 8180644227674226434.tmp
-rw------- 1 user user 56344 Jun 19 14:11 1162382849464709134.tmp
-rw------- 1 user user 56344 Jun 19 14:11 4473912385829326236.tmp
-rw------- 1 user user 59224 Jun 19 14:12 44816572340739296.tmp
-rw------- 1 user user 49416 Jun 19 14:29 2253955402032058887.tmp
-rw------- 1 user user 46076 Jun 19 14:54 2224021715630683512.tmp
-rw------- 1 user user 83472 Jun 19 15:25 455967079139355584.tmp
-rw------- 1 user user 83472 Jun 19 15:26 1074541420877403068.tmp
-rw------- 1 user user 46076 Jun 19 15:59 3632140460732481164.tmp
-rw------- 1 user user 45108 Jun 19 17:30 8847261278086377700.tmp
-rw------- 1 user user 54000 Jun 19 18:02 8681044407184944721.tmp
-rw------- 1 user user 54564 Jun 19 20:01 7703927324243684958.tmp
-rw------- 1 user user 54564 Jun 19 20:01 7448280277407508823.tmp
-rw------- 1 user user 54564 Jun 19 20:01 7069154843842198769.tmp
-rw------- 1 user user 54564 Jun 19 20:02 1431729105371009759.tmp
-rw------- 1 user user 54564 Jun 19 20:02 8359037531819485082.tmp
-rw------- 1 user user 54564 Jun 19 20:03 6457682749783413761.tmp
-rw------- 1 user user 54564 Jun 19 20:03 2038572826201539987.tmp
-rw------- 1 user user 54564 Jun 19 20:04 6491355393264185784.tmp
-rw------- 1 user user 59224 Jun 19 20:16 2043006978494200118.tmp
-rw------- 1 user user 45108 Jun 19 20:17 6492540855183189725.tmp
-rw------- 1 user user 45108 Jun 19 20:17 6477956601825850231.tmp
-rw------- 1 user user 45108 Jun 19 20:18 1074194357181759005.tmp
-rw------- 1 user user 45108 Jun 19 20:19 5440321220011066253.tmp
-rw------- 1 user user 45108 Jun 19 20:19 260683267390104293.tmp
-rw------- 1 user user 45108 Jun 19 20:20 1824196232656746433.tmp
-rw------- 1 user user 45108 Jun 19 20:20 8724797559370142565.tmp
-rw------- 1 user user 45108 Jun 19 20:21 6397991201954236018.tmp
-rw------- 1 user user 72880 Jun 20 04:14 7838401226118727100.tmp
-rw------- 1 user user 72880 Jun 20 04:15 7801714965385023569.tmp
-rw------- 1 user user 45108 Jun 20 08:42 1274908829136861980.tmp
-rw------- 1 user user 52092 Jun 20 08:43 5780888862258234581.tmp
-rw------- 1 user user 38628 Jun 20 08:52 756204766770614860.tmp
-rw------- 1 user user 45108 Jun 20 08:52 7485022978628098434.tmp
-rw------- 1 user user 105900 Jun 20 09:11 7854932029957477444.tmp
-rw------- 1 user user 105900 Jun 20 09:11 3956354999155285593.tmp
-rw------- 1 user user 105900 Jun 20 09:11 3966927481297956709.tmp
-rw------- 1 user user 105900 Jun 20 09:12 1705387516049599565.tmp
-rw------- 1 user user 105900 Jun 20 09:12 2525082796466540228.tmp
-rw------- 1 user user 105900 Jun 20 09:13 1591380519419898347.tmp
-rw------- 1 user user 105900 Jun 20 09:13 1102639893375607994.tmp
-rw------- 1 user user 105900 Jun 20 09:13 5262767813878310145.tmp
-rw------- 1 user user 105900 Jun 20 09:13 3288610156358797188.tmp
-rw------- 1 user user 105900 Jun 20 09:14 5829119682812572228.tmp
-rw------- 1 user user 105900 Jun 20 09:14 2452109250260818709.tmp
-rw------- 1 user user 105900 Jun 20 09:14 4590122970450657628.tmp
-rw------- 1 user user 105900 Jun 20 09:14 2294389195637964118.tmp
-rw------- 1 user user 105900 Jun 20 09:15 1676044168282755245.tmp
-rw------- 1 user user 105900 Jun 20 09:15 4366308640611104547.tmp
-rw------- 1 user user 46076 Jun 20 10:06 1107385874840309577.tmp
-rw------- 1 user user 41972 Jun 20 10:27 1085531486653661362.tmp
-rw------- 1 user user 62420 Jun 20 10:27 2101806982432516818.tmp
-rw------- 1 user user 62420 Jun 20 10:53 1624354934648606290.tmp
-rw------- 1 user user 65568 Jun 20 10:53 7654095057348026506.tmp
-rw------- 1 user user 65568 Jun 20 10:54 7700552507815118770.tmp
-rw------- 1 user user 65568 Jun 20 10:54 6308712112426443403.tmp
-rw------- 1 user user 102740 Jun 20 11:00 8795448846476018069.tmp
-rw------- 1 user user 52092 Jun 20 12:54 500845023343173208.tmp
-rw------- 1 user user 46076 Jun 20 12:54 3121276696569990545.tmp
-rw------- 1 user user 49416 Jun 20 13:46 5340608448298127831.tmp
-rw------- 1 user user 45108 Jun 20 13:46 6205360401301143413.tmp
-rw------- 1 user user 46076 Jun 20 13:59 855287858467535972.tmp
-rw------- 1 user user 56344 Jun 20 14:06 1803842700206075916.tmp
-rw------- 1 user user 46076 Jun 20 14:37 6491060217824383745.tmp
-rw------- 1 user user 45108 Jun 20 15:22 4328564943420472688.tmp
-rw------- 1 user user 45108 Jun 20 15:22 673290658104000296.tmp
-rw------- 1 user user 62804 Jun 20 15:22 3787216729224135023.tmp
-rw------- 1 user user 56344 Jun 20 21:08 4510338970233080762.tmp
-rw------- 1 user user 41972 Jun 21 00:13 398372327339912681.tmp
-rw------- 1 user user 56344 Jun 21 00:13 6904086396325952937.tmp
-rw------- 1 user user 59608 Jun 21 00:46 4051984352785933079.tmp
-rw------- 1 user user 127044 Jun 21 01:45 1935681615649757944.tmp
-rw------- 1 user user 55380 Jun 21 04:00 788398820398782761.tmp
-rw------- 1 user user 57600 Jun 21 04:00 3451867978654331939.tmp
-rw------- 1 user user 81900 Jun 21 06:09 3933771831691223539.tmp
-rw------- 1 user user 41304 Jun 21 06:10 5072654537578520166.tmp
-rw------- 1 user user 63668 Jun 21 06:10 8226596435615677441.tmp
-rw------- 1 user user 52092 Jun 21 07:48 7828279481225944808.tmp
-rw------- 1 user user 45684 Jun 21 10:30 2656910068365164057.tmp
-rw------- 1 user user 45108 Jun 21 10:31 195381961836753748.tmp
-rw------- 1 user user 43520 Jun 21 12:17 2400956652998491214.tmp
-rw------- 1 user user 49416 Jun 21 12:17 30508930089948393.tmp
-rw------- 1 user user 46020 Jun 21 12:17 6661846546424060419.tmp
-rw------- 1 user user 138036 Jun 21 12:17 5959997606181451969.tmp
-rw------- 1 user user 77388 Jun 21 13:03 331824420489889105.tmp
-rw------- 1 user user 52092 Jun 21 13:04 3758738812509306383.tmp
-rw------- 1 user user 45108 Jun 21 13:37 7496237755092762906.tmp
-rw------- 1 user user 59608 Jun 21 13:38 6544683383068478158.tmp
-rw------- 1 user user 52092 Jun 21 14:16 5731163136062904185.tmp
-rw------- 1 user user 45108 Jun 21 16:18 5547529479186863324.tmp
-rw------- 1 user user 171212 Jun 21 16:20 8323838581661442775.tmp
-rw------- 1 user user 42904 Jun 21 16:20 7250838806301761089.tmp
-rw------- 1 user user 171212 Jun 21 16:20 813682571379587717.tmp
-rw------- 1 user user 171212 Jun 21 16:20 8291233772358876144.tmp
-rw------- 1 user user 42904 Jun 21 16:20 4576361552735460033.tmp
-rw------- 1 user user 171212 Jun 21 16:20 1380471275230087315.tmp
-rw------- 1 user user 42904 Jun 21 16:21 3773859160506116712.tmp
-rw------- 1 user user 42904 Jun 21 16:21 1093442959977787407.tmp
-rw------- 1 user user 45684 Jun 21 16:21 7132957373537332056.tmp
-rw------- 1 user user 81900 Jun 21 17:41 4874781119889192787.tmp
-rw------- 1 user user 81900 Jun 21 18:59 458733250710614684.tmp
-rw------- 1 user user 45108 Jun 21 18:59 8010533676207338451.tmp
-rw------- 1 user user 49416 Jun 21 22:47 6193537558164312069.tmp
-rw------- 1 user user 45108 Jun 21 22:47 5030888357164286514.tmp
-rw------- 1 user user 38628 Jun 22 01:53 5987612845570695845.tmp
-rw------- 1 user user 45108 Jun 22 01:53 8340424949591407739.tmp
Now running the command find . -mtime 1 -type f -exec ls -lrth "{}" \; gives me below list:
-rw------- 1 user user 62K Jun 20 15:22 3787216729224135023.tmp
-rw------- 1 user user 45K Jun 20 13:46 6205360401301143413.tmp
-rw------- 1 user user 104K Jun 20 09:14 2452109250260818709.tmp
-rw------- 1 user user 45K Jun 20 15:22 673290658104000296.tmp
-rw------- 1 user user 45K Jun 20 13:59 855287858467535972.tmp
-rw------- 1 user user 56K Jun 21 00:13 6904086396325952937.tmp
-rw------- 1 user user 104K Jun 20 09:14 2294389195637964118.tmp
-rw------- 1 user user 45K Jun 20 14:37 6491060217824383745.tmp
-rw------- 1 user user 125K Jun 21 01:45 1935681615649757944.tmp
-rw------- 1 user user 45K Jun 20 08:52 7485022978628098434.tmp
-rw------- 1 user user 104K Jun 20 09:14 5829119682812572228.tmp
-rw------- 1 user user 104K Jun 20 09:15 4366308640611104547.tmp
-rw------- 1 user user 104K Jun 20 09:12 1705387516049599565.tmp
-rw------- 1 user user 104K Jun 20 09:13 3288610156358797188.tmp
-rw------- 1 user user 104K Jun 20 09:11 7854932029957477444.tmp
-rw------- 1 user user 65K Jun 20 10:54 7700552507815118770.tmp
-rw------- 1 user user 45K Jun 20 15:22 4328564943420472688.tmp
-rw------- 1 user user 41K Jun 20 10:27 1085531486653661362.tmp
-rw------- 1 user user 51K Jun 20 08:43 5780888862258234581.tmp
-rw------- 1 user user 56K Jun 20 14:06 1803842700206075916.tmp
-rw------- 1 user user 72K Jun 20 04:15 7801714965385023569.tmp
-rw------- 1 user user 41K Jun 21 00:13 398372327339912681.tmp
-rw------- 1 user user 38K Jun 20 08:52 756204766770614860.tmp
-rw------- 1 user user 104K Jun 20 09:13 1591380519419898347.tmp
-rw------- 1 user user 49K Jun 20 13:46 5340608448298127831.tmp
-rw------- 1 user user 45K Jun 20 12:54 3121276696569990545.tmp
-rw------- 1 user user 104K Jun 20 09:15 1676044168282755245.tmp
-rw------- 1 user user 101K Jun 20 11:00 8795448846476018069.tmp
-rw------- 1 user user 104K Jun 20 09:11 3956354999155285593.tmp
-rw------- 1 user user 45K Jun 20 10:06 1107385874840309577.tmp
-rw------- 1 user user 61K Jun 20 10:27 2101806982432516818.tmp
-rw------- 1 user user 104K Jun 20 09:11 3966927481297956709.tmp
-rw------- 1 user user 72K Jun 20 04:14 7838401226118727100.tmp
-rw------- 1 user user 56K Jun 20 21:08 4510338970233080762.tmp
-rw------- 1 user user 51K Jun 20 12:54 500845023343173208.tmp
-rw------- 1 user user 104K Jun 20 09:12 2525082796466540228.tmp
-rw------- 1 user user 61K Jun 20 10:53 1624354934648606290.tmp
-rw------- 1 user user 65K Jun 20 10:54 6308712112426443403.tmp
-rw------- 1 user user 45K Jun 20 08:42 1274908829136861980.tmp
-rw------- 1 user user 59K Jun 21 00:46 4051984352785933079.tmp
-rw------- 1 user user 104K Jun 20 09:14 4590122970450657628.tmp
-rw------- 1 user user 104K Jun 20 09:13 5262767813878310145.tmp
-rw------- 1 user user 65K Jun 20 10:53 7654095057348026506.tmp
-rw------- 1 user user 104K Jun 20 09:13 1102639893375607994.tmp
I was expecting all the files which are dated Jun 18, Jun 19, Jun 20, Jun 21. The Jun 21 files can be restricted to files which or older than 24Hrs. But the command is giving only Jun 20 & Jun 21 files which are older than 24Hrs but ignoring Jun 18 & Jun 19 files.
find allows just that using -mtime option as explained in the answer here which does the trick for you.
The answer you are looking forward to is below, which finds files that were modified exactly between 1 and 2 days ago.
-mtime 1 (the actual answer)
find /sourcedirectory -mtime 1 -type f -exec ls -lrth "{}" \; -exec rm "{}" \;
in general finds files that were last modified between N and N+1 days ago.
will be just sufficient for listing and deleting the files. You can use any number of -exec's as long as you follow the syntax.
Other options work as follows:-
-mtime +N -> files modified at least N+1 days ago
-mtime -N -> files modified less than N days ago
I have to retrieve an existing symfony2 (2.1.13) project from prod server in order to run it locally to make some changes. The problem is the architecture seems to be a little bit strange. Please have a look on it :
$pwd
/var/www/html/sites/www.mysite.com
drwxr-xr-x 2 ... 4.0K Jun 30 09:30 backups/
drwxr-x--- 2 ... 6 Mar 15 2013 cgi-bin/
drwxr-xr-x 4 ... 41 Aug 10 18:09 _copie1/
drwxr-xr-x 2 ... 6 Apr 25 2014 log/
drwxr-xr-x 12 ... 4.0K Aug 11 15:41 releases/
drwxr-xr-x 7 ... 146 May 12 16:46 repo/
drwxr-xr-x 5 ... 85 May 12 16:49 shared/
lrwxrwxrwx 1 ... 58 Jul 6 15:11 current -> /var/www/html/sites/www.mysite.com/releases/201508/
lrwxrwxrwx 1 ... 12 Mar 28 2013 html -> current/web//
-rw-r--r-- 1 ... 1022 Jul 6 15:11 revisions.log
current/
drwxr-xr-x 6 ... 4.0K Jul 6 15:09 app/
drwxr-xr-x 2 ... 124 Jul 6 15:05 bin/
drwxr-xr-x 4 ... 50 Aug 11 14:54 src/
drwxr-xr-x 35 ... 4.0K Aug 11 12:08 vendor/
drwxr-xr-x 5 ... 4.0K Aug 11 18:28 web/
-rw-r--r-- 1 ... 626 Jul 6 15:05 Capfile
-rw-r--r-- 1 ... 4.1K Jul 6 15:05 composer.json
-rw-r--r-- 1 ... 167K Jul 6 15:05 composer.lock
-rw-r--r-- 1 ... 216 Jul 6 15:05 Gemfile
-rw-r--r-- 1 ... 1.2K Jul 6 15:05 Gemfile.lock
-rw-r--r-- 1 ... 1.1K Jul 6 15:05 LICENSE
-rw-r--r-- 1 ... 1.6K Jul 6 15:05 README.md
-rw-r--r-- 1 ... 8 Jul 6 15:06 REVISION
-rw-r--r-- 1 ... 7.7K Jul 6 15:05 UPGRADE.md
-rw-r--r-- 1 ... 7 Jul 6 15:05 VERSION
current/web/
drwxr-xr-x 2 ... 4.0K Aug 11 12:10 bundles/
drwxr-xr-x 4 ... 4.0K Jul 6 15:11 compiled/
drwxr-xr-x 2 ... 47 Jul 6 15:11 js/
-rw-r--r-- 1 ... 46K Jul 6 15:11 apc.php
-rw-r--r-- 1 ... 11K Jul 6 15:05 apple-touch-icon.png
-rw-r--r-- 1 ... 7.0K Jul 6 15:05 apple-touch-icon-precomposed.png
-rw-r--r-- 1 ... 728 Jul 6 15:05 app.php
-rw-r--r-- 1 ... 33K Jul 6 15:05 favicon.ico
-rw-r--r-- 1 ... 20K Jul 6 15:05 favicon.jpg
-rw-r--r-- 1 ... 4.6K Jul 6 15:05 favicon.png
lrwxrwxrwx 1 ... 51 Jul 6 15:06 image -> /var/www/html/sites/www.mysite.com/shared/web/image/
lrwxrwxrwx 1 ... 52 Jul 6 15:06 medias -> /var/www/html/sites/www.mysite.com/shared/web/medias/
-rw-r--r-- 1 ... 66 Aug 10 12:28 robots.txt
-rw-r--r-- 1 ... 2.2M Aug 11 03:00 sitemap.xml
current/web/bundles/
lrwxrwxrwx 1 ... 147 Jul 6 15:09 bazingaexposetranslation -> /var/www/html/sites/www.mysite.com/releases/201508/vendor/willdurand/js-translation-bundle/Bazinga/ExposeTranslationBundle/Resources/public/
lrwxrwxrwx 1 ... 121 Jul 6 15:09 ericharddms -> /var/www/html/sites/www.mysite.com/releases/201508/vendor/erichard/dms-bundle/Erichard/DmsBundle/Resources/public/
lrwxrwxrwx 1 ... 126 Jul 6 15:09 farosadmin -> /var/www/html/sites/www.mysite.com/releases/201508/vendor/faros/admin-bundle-legacy/Faros/AdminBundle/Resources/public/
lrwxrwxrwx 1 ... 125 Jul 6 15:09 faroselfinder -> /var/www/html/sites/www.mysite.com/releases/201508/vendor/faros/elfinder-bundle/Faros/ElFinderBundle/Resources/public/
lrwxrwxrwx 1 ... 113 Jul 6 15:09 farosqb -> /var/www/html/sites/www.mysite.com/releases/201508/vendor/faros/qb-bundle/Faros/QBBundle/Resources/public/
lrwxrwxrwx 1 ... 116 Jul 6 15:09 fosjsrouting -> /var/www/html/sites/www.mysite.com/releases/201508/vendor/friendsofsymfony/jsrouting-bundle/Resources/public/
lrwxrwxrwx 1 ... 133 Jul 6 15:09 framework -> /var/www/html/sites/www.mysite.com/releases/201508/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/public/
lrwxrwxrwx 1 ... 132 Jul 6 15:09 mopabootstrap -> /var/www/html/sites/www.mysite.com/releases/201508/vendor/mopa/bootstrap-bundle/Mopa/Bundle/BootstrapBundle/Resources/public/
lrwxrwxrwx 1 ... 129 Jul 6 15:09 trsteelckeditor -> /var/www/html/sites/www.mysite.com/releases/201508/vendor/trsteel/ckeditor-bundle/Trsteel/CkeditorBundle/Resources/public/
lrwxrwxrwx 1 ... 99 Jul 6 15:09 mysiteadmin -> /var/www/html/sites/www.mysite.com/releases/201508/src/mysite/AdminBundle/Resources/public/
lrwxrwxrwx 1 ... 98 Jul 6 15:09 mysitesite -> /var/www/html/sites/www.mysite.com/releases/201508/src/mysite/SiteBundle/Resources/public/
current/app/
drwxr-xr-x 4 ... 27 Aug 11 18:32 cache/
drwxr-xr-x 3 ... 4.0K Aug 11 12:12 config/
drwxr-xr-x 2 ... 4.0K Jul 6 15:05 DoctrineMigrations/
drwxr-xr-x 8 ... 105 Jul 6 15:06 Resources/
-rw-r--r-- 1 ... 141 Jul 6 15:05 AppCache.php
-rw-r--r-- 1 ... 4.3K Jul 6 15:05 AppKernel.php
-rw-r--r-- 1 ... 474 Jul 6 15:05 autoload.php
-rw-r--r-- 1 ... 48K Jul 6 15:09 bootstrap.php.cache
-rw-r--r-- 1 ... 1.7K Jul 6 15:09 check.php
-rwxr-xr-x 1 ... 794 Jul 6 15:05 console*
lrwxrwxrwx 1 ... 50 Jul 6 15:06 logs -> /var/www/html/sites/www.mysite.com/shared/app/logs/
-rw-r--r-- 1 ... 1.7K Jul 6 15:05 phpunit.xml.dist
-rw-r--r-- 1 ... 26K Jul 6 15:09 SymfonyRequirements.php
lrwxrwxrwx 1 ... 49 Jul 6 15:06 var -> /var/www/html/sites/www.mysite.com/shared/app/var/
As you can see there are so many symlinks :(
I have a new installation of symfony 2.1.13 on my wamp server, so :
1. What should I exactly copy from the server ?
2. And where to copy ?
3. How to configure files like AppKernel.php, config.php, parameters.yml ...
Thanks :)
Looks like you are stepped to the task from apposite side
First of all "strange" folders architecture is comming from the nature of the deployment tool "capifony". You can see folder "releases" that keeps all history of releases deployed and folder(symlink) "current" that points to the latest(current) release. Also you can see some symlinks to the folder "shared" that suppose to keep some content that doesn't suppose change from deploy to deploy (like images, logs).
It is possible to explain long how capifony works, but seems it is better to get some quick overview http://capifony.org/
In short words I can say that you can copy the site to local, but it is not the best way. I suppose you need to clone the project from its repository(most probably git) and setup parameters.yml
You should not change AppKernel.php or config.php
Clone the respository and looks for app/config/parameters.yml.dist that will(should) have initial configuration for the project
PS: you should not copy "current/web/bundles/" but should use "assets install" command to create these assets
PPS: And I believe you should to learn some symfony docs(at least basic) before start to copy the site