Bazen sistemde neler olduğunu log dosyalarını okuyarak veya realtime olarak takip edip öğrenebiliriz. Bu işlem için tail komutu kullanılabilir. Bu yazımızda Apache'nin log dosyasını okuyacağız ama siz istediğniz log dosyasını okuyabilirsiniz mesela sistem logları "/var/log/syslog".


Son 5 log mesajıni okuyalım


inanzzz@inanzzz:~$ tail -n5 /var/log/apache2/error.log
[Sat Mar 28 09:29:23.375241 2015] [mpm_prefork:notice] [pid 5557] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.5 configured -- resuming normal operations
[Sat Mar 28 09:29:23.375337 2015] [core:notice] [pid 5557] AH00094: Command line: '/usr/sbin/apache2'
[Sat Mar 28 09:31:00.201426 2015] [mpm_prefork:notice] [pid 5557] AH00169: caught SIGTERM, shutting down
[Sat Mar 28 09:31:01.291222 2015] [mpm_prefork:notice] [pid 5643] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.5 configured -- resuming normal operations
[Sat Mar 28 09:31:01.291321 2015] [core:notice] [pid 5643] AH00094: Command line: '/usr/sbin/apache2'

Realtime olarak log takip etmek


inanzzz@inanzzz:~$ tail -f /var/log/apache2/error.log
[Sat Mar 28 09:20:34.641915 2015] [core:notice] [pid 5284] AH00094: Command line: '/usr/sbin/apache2'
[Sat Mar 28 09:26:16.628067 2015] [mpm_prefork:notice] [pid 5284] AH00169: caught SIGTERM, shutting down
[Sat Mar 28 09:26:17.746466 2015] [mpm_prefork:notice] [pid 5435] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.5 configured -- resuming normal operations
[Sat Mar 28 09:26:17.746565 2015] [core:notice] [pid 5435] AH00094: Command line: '/usr/sbin/apache2'
[Sat Mar 28 09:29:22.232717 2015] [mpm_prefork:notice] [pid 5435] AH00169: caught SIGTERM, shutting down
[Sat Mar 28 09:29:23.375241 2015] [mpm_prefork:notice] [pid 5557] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.5 configured -- resuming normal operations
[Sat Mar 28 09:29:23.375337 2015] [core:notice] [pid 5557] AH00094: Command line: '/usr/sbin/apache2'
[Sat Mar 28 09:31:00.201426 2015] [mpm_prefork:notice] [pid 5557] AH00169: caught SIGTERM, shutting down
[Sat Mar 28 09:31:01.291222 2015] [mpm_prefork:notice] [pid 5643] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.5 configured -- resuming normal operations
[Sat Mar 28 09:31:01.291321 2015] [core:notice] [pid 5643] AH00094: Command line: '/usr/sbin/apache2'