Delete log file in LINUX [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have several log file in my tomcat folder - /var/lib/tomcat9/logs
drwxrwxr-x 11 root syslog 4096 Oct 01 06:25 ../
-rw-r----- 1 tomcat tomcat 5077 Oct 01 11:54 catalina.2020-10-01.log
-rw-r----- 1 tomcat tomcat 0 Oct 01 11:54 localhost.2020-10-01.log
-rw-r----- 1 tomcat tomcat 115 Oct 01 11:57 localhost_access_log..2020-10-01.txt
-rw-r----- 1 root root 1716 Oct 01 11:57 restful.2020-10-01.log
-rw-r----- 1 root root 1716 Oct 02 11:57 restful.2020-10-02.log
-rw-r----- 1 root root 1716 Oct 03 11:57 restful.2020-10-03.log
-rw-r----- 1 tomcat tomcat 1716 Oct 19 11:57 restful.log
I run the command find /var/lib/tomcat9/logs/ -type f -mtime +2 -exec rm {} ;
It delete all the file including the catalina file and localhost file.
May I know how to delete file not later than 2 days but not incuding catalina and localhost file.
Thank you.

find /var/lib/tomcat9/logs/ -type f -name "restful*" -mtime +10 -exec rm {} \;

Related

Permission denied - Even tho in group with ownership [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I've created a group "certificates" and put this group as chgrp -R to /root/ca and all it's files!
Even tho I'm member of "certificates" (relooged multiple times even restarted server) and the permissions are set on drwsrwsr-x I still get the error "Permission denied" when trying to "cd /root/ca".
I tried chaning permissions and ownership and more but somehow still can't access the folder nor get any information about the folder without using "sudo".
Anyone got an idea what could be causing the problem and how to fix it, so I can access the folder if I am member of certificates?
adm_mike#sf-svr-crt01:~$ id -NG
adm_mike adm cdrom sudo dip plugdev lxd certificates
adm_mike#sf-svr-crt01:~$ sudo ls -lh /root | grep ca
drwsrwsr-x 8 root certificates 4.0K Aug 18 06:25 ca
adm_mike#sf-svr-crt01:~$ sudo ls -lh /root/ca
drwsrwsr-x 2 root certificates 4.0K Aug 18 06:28 certs
drwsrwsr-x 2 root certificates 4.0K Aug 18 06:00 config
drwsrwsr-x 2 root certificates 4.0K Aug 13 06:36 crl
-rwxrwxr-x 1 root certificates 5 Aug 13 06:37 crlnumber
-rwxrwxr-x 1 root certificates 579 Aug 18 06:25 index.txt
-rwxrwxr-x 1 root certificates 21 Aug 18 06:25 index.txt.attr
-rwxrwxr-x 1 root certificates 21 Aug 16 15:21 index.txt.attr.old
-rwxrwxr-x 1 root certificates 423 Aug 16 15:21 index.txt.old
drwsrwsr-x 2 root certificates 4.0K Aug 18 06:25 newcerts
drwsrwsr-x 2 root certificates 4.0K Aug 17 14:16 private
drwsrwsr-x 2 root certificates 4.0K Aug 18 06:13 request
-rwxrwxr-x 1 root certificates 5 Aug 18 06:25 serial
-rwxrwxr-x 1 root certificates 5 Aug 16 15:21 serial.old
adm_mike#sf-svr-crt01:~$ cd /root/ca
-bash: cd: /root/ca: Permission denied
Linux Codes as Image
In order to change to the directory /root/ca, you also need to have execute (x) permissions on top-level directories - in this case /root. Whilst in theory the solution would be to also change the group of /root, this is not recommended, as /root, should stay only accessible by the root user in all cases.
You should make a directory in a separate location, i.e. /etc/ssl/ca, and set the respective permissions there.

Logfiles ending with ".1" [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
Why my logsfiles ending with ".1" ?
Its just a new file for log ?
-rw-r----- 1 root adm 0 Mar 14 10:56 auth.log
-rw-r----- 1 root adm 8998827 Mar 14 00:00 auth.log.1
-rw-r----- 1 root adm 5241 Mar 14 10:55 daemon.log
-rw-r----- 1 root adm 97769 Mar 14 00:00 daemon.log.1
-rw-r----- 1 root adm 0 Mar 14 00:00 debug
-rw-r----- 1 root adm 16853 Mar 11 20:51 debug.1
-rw-r----- 1 root adm 0 Mar 14 00:00 kern.log
-rw-r----- 1 root adm 87015 Mar 11 20:51 kern.log.1
-rw-rw-r-- 1 root utmp 292292 Mar 14 10:39 lastlog
-rw-r----- 1 root adm 154 Mar 14 00:00 messages
-rw-r----- 1 root adm 73418 Mar 14 00:00 messages.1
-rw-r----- 1 root adm 0 Mar 14 00:00 user.log
-rw-r----- 1 root adm 2168 Mar 11 20:51 user.log.1
It looks like logrotate in action. That's how it works:
Log rotation is the process that renames a current log file (e.g.,
auth.log becomes auth.log.1) and sets up a new log file (e.g.,
auth.log) for new log entries.
Rotating log files is important for several reasons. First, you
probably don't want older log files eating up too much of your disk
space. Second, when you need to analyze log data, you probably don't
want those log files to be extremely large and cumbersome. And last,
organizing log files by date probably makes spotting and analyzing
changes quite a bit easier (e.g., comparing last week's log data to
this week's).
You didn't mention the OS in question: this article, for example, described how one can set up and configure logrotate on Ubuntu 16.04.

Mac OSX file permissions has '#' - how to remove that '#' [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
How can I remove that '#' character from the file permissions?
'#' in file permissions for Mac/OSX machines, is used to show that an extended attribute is set with this file.
Tried chmod 755 galaxy-ansible.yml but that didn't help.
Tried echo | chmod -E galaxy-ansible.yml, didn't help (even with using sudo).
Tried xattr -d galaxy-ansible.yml, that didn't help either (even with using sudo).
I even did the above operations as root user, still '#' character is not going away from file's permissions.
[arun#MacBook-Pro-2 ~/aks/anisble] $ ls -l# galaxy-ansible.yml
-rwxr-xr-x# 1 arun staff 270 Dec 22 12:31 galaxy-ansible.yml
com.apple.quarantine 67
My ~/aks folder is mapped to a CentOS vagrant box and if I'm on the vagrant box, doing ls -l doesn't give me '#' (as it's not a Max/OSX machine):
-rwxr-xr-x. 1 vagrant vagrant 270 Dec 22 00:12 galaxy-ansible.yml
On my Mac/OSX machine, there are other .yml files but those don't have '#' in the file permissions so I'm trying to remove '#' from galaxy-ansible.yml file (on Mac machine).
Right now the whole roles/.. folder has '#' character for any folder/files.
-rwxr-xr-x# 1 arun staff 1132 Dec 21 17:12 README.md
drwxr-xr-x# 3 arun staff 102 Dec 21 17:12 defaults
drwxr-xr-x# 3 arun staff 102 Dec 21 17:12 handlers
drwxr-xr-x# 4 arun staff 136 Dec 21 17:12 meta
drwxr-xr-x# 5 arun staff 170 Dec 21 17:12 tasks
drwxr-xr-x# 7 arun staff 238 Dec 21 17:12 templates
The following commands helped in clearing the extended attribute at file / folder(recursive) level.
xattr -c <yourfilename>
or
xattr -cr <yourfoldername>

Linux memory issue [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I have a problem on my server.
When i try to start my server, it says that "there no left space on device"
If i execute the command "df", I see that on directory if full.
/dev/mapper/owegdc_vg-owegdc_logs_lv
10321208 9797004 0 100% /opt/application/owegdc/logs
When i get to the logs directory here what i see
ls -lrta
total 368
drwxr-x--- 2 oweadm grpowe 16384 Jan 15 2014 lost+found
drwxr-x--- 7 oweadm grpowe 4096 Jun 18 11:55 .
drwxr-xr-x 2 oweadm grpowe 12288 Aug 4 10:20 apache
drwxr-xr-x 2 oweadm grpowe 4096 Aug 5 00:56 batches
drwxr-xr-x 2 oweadm grpowe 4096 Sep 10 13:43 expl
drwxr-xr-x 2 oweadm grpowe 327680 Sep 10 13:50 jonas
drwxr-xr-x 11 oweadm grpowe 4096 Sep 10 13:50 ..
du -sk
9642792 .
I tried things like 'lsof' but it didn't work...
Do you have an idea ?
Thx
You could just try something like
du | sort -h -r
That would list the directories on your disk, ordered by their size descending. The first directory in the output list is the biggest one.
Better, if you're looking for large single files instead of a directory, this answer on Unix & Linux gives useful information, especially this:
find . -type f | xargs du -h | sort -rn
The output is the same, but it lists files instead of dirs.

linux permissions on aws : basic [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I am new to linux and I am having a problem with permissions. Quite a long time ago I had created an AWS EC2 instance from scratch using step by step tutorials scattered over the web. I managed to upload an html website over there and linking the domain to it etc...
Now that after six months I am connecting again to the EC2 instance using MobaXTerm SSH or SFTP session, I can't get to upload new files or rename old files etc. I am using the regular ec2-user which from what I understand is quite a privileged user nearly as permissable as root.
I connect successfully with the old key that I had created and I can arrive to the desired directory. But I simply can't upload new files or replace old ones because I get a permission denied error. I don't know why and how to fix.
Last login: Fri Apr 25 13:18:26 2014 from 85.232.210.97
__| __|_ )
_| ( / Amazon Linux AMI
___|\___|___|
https://aws.amazon.com/amazon-linux-ami/2014.03-release-notes/
[ec2-user#ip-172-31-47-208 ~]$ cd ./var/www/html/
-bash: cd: ./var/www/html/: No such file or directory
[ec2-user#ip-172-31-47-208 ~]$ cd .
[ec2-user#ip-172-31-47-208 ~]$ cd ..
[ec2-user#ip-172-31-47-208 home]$ cd ..
[ec2-user#ip-172-31-47-208 /]$ cd var/www/html/
**[ec2-user#ip-172-31-47-208 html]$ mv index.html index_old.html
mv: cannot move ‘index.html’ to ‘index_old.html’: Permission denied**
[ec2-user#ip-172-31-47-208 html]$ ls -l
total 164
drwxrwxr-x 2 ec2-user ec2-user 4096 Mar 27 16:03 css
-rw-rw-r-- 1 ec2-user ec2-user 5686 Mar 25 08:34 favicon.ico
drwxrwxr-x 2 ec2-user ec2-user 4096 Mar 27 16:04 font
drwxrwxr-x 14 ec2-user ec2-user 4096 Mar 27 16:18 images
**-rwxrwxrwx 1 ec2-user ec2-user 48675 Apr 25 13:41 index.html**
drwxrwxr-x 4 ec2-user ec2-user 4096 Mar 27 16:19 js
drwxrwxr-x 3 ec2-user ec2-user 4096 Mar 27 16:20 nbproject
drwxrwxrwx 2 ec2-user ec2-user 4096 Apr 25 13:30 old
drwxrwxr-x 3 ec2-user ec2-user 4096 Mar 27 16:20 php
-rw-rw-r-- 1 ec2-user ec2-user 41041 Sep 17 2013 PIE.htc
drwxrwxr-x 24 ec2-user ec2-user 4096 Mar 27 16:22 skins
-rw-rw-r-- 1 ec2-user ec2-user 30951 Mar 26 19:07 style.css
[ec2-user#ip-172-31-47-208 html]$
Can you guide me? What to check? Where to start and continue to dig to sort the issue?
I used WinSCP and SFTP also to manage file uploads easily but the permission issue remains unchanged.
Thank you
In order to add or remove files to/from a directory, you need to have write permission on the directory in question, which is /var/www/html in your case.(I originally wrote just a comment, but thinking again there is only one reason why you see what you are seeing.)Use ls -ld /var/www/html to have a look at the permissions on the directory itself. It should probably belong to root:ec2-user, which in turn means it should likely be chmod 775 (owner and group have read/write/execute permission, others may not write).

Resources