Skip to content

find by date and tar them

find by date and tar them published on No Comments on find by date and tar them

If you have a big log folder and you want to tar the newest log files in to one tar.gz file, then you can use the following:

find /opt/tomcat/logs/ -type f -newermt 2013-06-09 | tar cvzf testfind.tar.gz -T - --null

I do not know the meaning of -T - --null, but it works.

 

Perhaps your find version is to old for the newermt statement. With find version 4.2.27 it did not work. Then you could use -mtime, for modification time.
mtime is the number * 24 h, do find all files older newer then one day, you can use:

find /opt/tomcat/logs/ -type f -mtime 1

+1 would mean older than one day

Upgrade PostgreSQL Database from 9.4 to 9.6 on openSUSE

Upgrade PostgreSQL Database from 9.4 to 9.6 on openSUSE published on No Comments on Upgrade PostgreSQL Database from 9.4 to 9.6 on openSUSE

This tutorial shows how to upgrade PostgreSQL from 9.4 (openSUSE 42.2) to 9.6 (openSUSE 42.3)

  1. Stop postgresql and disable service
    systemctl stop postgresql.service
    systemctl disable postgresql.service
  2. Install PostgreSQL 9.6 (9.4 should still be installed after the update)
    zypper -n install postgresql96 postgresql96-server postgresql96-contrib
  3. Move current cluster and create new data dir with user postgres
    mv /var/lib/pgsql/data/ /var/lib/pgsql/data94/
    su postgres -c "mkdir /var/lib/pgsql/data"
    
  4. Enable service, start it to create new database cluster at data folder, and stop service again to prepare the following upgrade
    systemctl enable postgresql.service
    systemctl start postgresql.service
    systemctl stop postgresql.service
  5. Run pg_upgrade where -b is old bin dir, -B is new bin dir, -d is old data dir, and -D new data dir. This must run as user postgres ( su - postgres )
    su - postgres -c "pg_upgrade -b /usr/lib/postgresql94/bin/ -B /usr/lib/postgresql96/bin/ -d /var/lib/pgsql/data94/ -D /var/lib/pgsql/data"
  6. Copy the pg_hba.conf from old data dir to the new one (if you changed something at postgresql.conf you could copy that to the new data folder too). After that, start the postgresql service.
    cp /var/lib/pgsql/data94/pg_hba.conf /var/lib/pgsql/data
    systemctl start postgresql.service
  7. Try to login to postgresql, Version 9.6.x should be printed, leave with \q
     # psql -U postgres
    psql (9.6.4)
    Type "help" for help.
    
    postgres=# \q
  8. If you don't need the old cluster data, run this:
    /var/lib/pgsql/delete_old_cluster.sh

Links for journalctl

Links for journalctl published on No Comments on Links for journalctl

Allgemeine Infos zu journalctl:
https://www.digitalocean.com/community/tutorials/how-to-use-journalctl-to-view-and-manipulate-systemd-logs

journalctl -u tomcat7.service

Speichereinstellung für das Journal ändern

Quelle ubuntuusers.de
Wie (und ob) das Journal gespeichert wird, wird über den Wert des Schlüssels Storage geregelt. Unter Ubuntu ist der Standardwert auto. Dabei wird die Journal-Datei im Verzeichnis/run/log/UUID_DES_VERZEICHNISSES/ angelegt und geht nach dem Herunterfahren des Systems verloren.

Damit die Journaldateien - und damit alle Logs - für längere Zeit gespeichert werden, gibt es zwei Möglichkeiten:

  • Man legt das Verzeichnis /var/log/journal/ an. Nach dem Neustart des Systems wird die Journal dort gespeichert und bleibt somit auch nach einem Neustart des Systems bestehen.
  • Man ändert in der Konfigurationsdatei den Wert die Zeile
    Storage=auto
    auf
    Storage=persistent

Nach einem Neustart des Systems wird der Ordner /var/log/journal/ automatisch angelegt und das Journal wird dort dauerhaft gespeichert.

Randomized collection of useful linux commands

Randomized collection of useful linux commands published on No Comments on Randomized collection of useful linux commands

Cut some rows
cut -d " " -f2-4 messages

with tee we drop shit in a file and in stdout
grep kernel /var/log/messages | tee /root/my.log

with xargs we give in this expample the command host the output line by line:
cut -d " " -f1 localhost_access_log.2014-11-19.txt | sort | uniq | xargs -n1 host

ps -C tail
ps and show all processes of the program tail

pstree -pna
-p = show PID
-n = sort by PID
-a = shows options and arguments

top -bi -d 1 > file.txt
-b = batch mode to put it in a file
-i = show only the active ones
-d 1 = every 1 sec
Like that the file.txt has every second the active processes in top

kill -l shows you all available signals you can send to the process
1) SIGHUP: Hang-up-signal, for daemons to reload their config
9) SIGKILL: to kill the process
15) SIGTERM: to terminate the process
other
2) SIGINT: like Ctrl+C, but much more fun
18) SIGCONT: continue processes which are put in the background with bg and fg (or with 19)
19) SIGSTOP: bg, but also much more fun
20) SIGSTP: like ctrl+z.

with w we see the logged in users