Logrotate basics

By default, logrotate runs once a day, using a cron scheduler from /etc/cron.daily/

# ls /etc/cron.daily/
logrotate

Configuration files for logrotate:

  • default configuration /etc/logrotate.conf:
$ cat /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# use date as a suffix of the rotated file
dateext

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# system-specific logs may be also be configured here.

Continue reading “Logrotate basics”

Leaving incrond for systemd.path

I’ve been having problems with incrond for months; after trying to upgrade from version 0.5.10, incrond would not trigger after a specified event occurred in the monitored path.

After upgrading to version 0.5.12-9 (I couldn’t use 0.5.10 because of security policies), incrond has started behaving in a completely random way: sometimes it was triggered as expected but some other times (way too many), nothing was happening.

This was the entry in incrontab:

/home/elena/upload IN_CLOSE_WRITE /bin/find $@ -type f -exec /bin/chmod g+rw {} \+

Writing a script and adding it to crontab was out of question; here is where systemd came in handy, with path units.

A .path unit (systemd.path) monitors a file or directory and it calls a .service unit (systemd.service), usually with the same name, when something happens to the monitored file or directory. Continue reading “Leaving incrond for systemd.path”

AWK basics

Printing columns

Print all the columns:

$ awk '{print $0}' FILE

Print the 1 column:

$ awk '{print $1}' FILE

Print the last column:

$ awk '{print $NF}' FILE

Print multiple columns:

$ awk '{print $1 $3}' FILE

Specifying field separator

By default, awk uses space and tab as field separator. You can specify how fields are separated using the -F option.

$ awk -F "/" '{print $1}' FILE

Excluding columns

Print all the columns but not the 2 one:

$ awk '{$2=""; print $0}' FILE

Print all the columns but not 1 and 2:

$ awk '{$1=$2=""; print $0}' FILE

 

SSH: No supported key exchange algorithms [preauth]

I’ve recently installed Solaris 11.4 on a VM and, as soon as I tried to log in remotely using SSH, my connection was refused straight away. First of all, I checked if the service was enabled:

$ svcs ssh
STATE          STIME    FMRI
online         13:23:15 svc:/network/ssh:default

I checked SSH directory under /etc and something was definitely not quite right with the auto-generated keys:

-rw-------   1 root     root         0 Jan  4 13:23 ssh_host_ed25519_key
-rw-r--r--   1 root     root         0 Jan  4 13:23 ssh_host_ed25519_key.pub
-rw-------   1 root     root         0 Jan  4 13:23 ssh_host_rsa_key
-rw-r--r--   1 root     root         0 Jan  4 13:23 ssh_host_rsa_key.pub

The keys were there… but truncated to zero.

Something, somewhere went wrong during the key generation (usually when OpenSSH is run for the first time) so I deleted the keys and restarted the service:

# svcadm restart ssh

The keys were re-generated and I was able to log in.