Menu

Showing posts with label syslog. Show all posts
Showing posts with label syslog. Show all posts

Friday, January 15, 2021

[System - Linux] วิธีการตรวจสอบข้อมูล Log ของ Cron บน Linux Server แต่ละประเภท
[System - Linux] How to Find Cron Logs on Each Type of Linux Server

Ubuntu และ Debian

ข้อมูล log ของ cron จะถูกรวมอยู่ใน /var/log/syslog 

วิธีการตรวจสอบ log ให้ใช้คำสั่งดังนี้

grep CRON /var/log/syslog

CentOS and Redhat

ข้อมูล log ของ cron จะแยกไว้ที่ /var/log/cron 

วิธีการตรวจสอบ log ให้ใช้คำสั่งดังนี้

tail /var/log/cron

Saturday, August 3, 2019

[PHP] วิธีการพิมพ์ข้อความออกทาง STDOUT หรือ STDERR หรือ SYSLOG
[PHP] How to Print Out Message to STDOUT or STDERR or SYSLOG

ในบางครั้งคุณมีความจำเป็นต้องพิมพ์ข้อความออกทาง system log หรือ I/O streams อื่นๆ เช่น standard output, standard error

สมมติว่า $str เป็นข้อความที่คุณต้องการ print

คุณสามารถใช้ method ข้างล่างสำหรับการพิมพ์ข้อความออก system log
syslog(LOG_INFO, $str);
อ่านข้อมูลเพิ่มเติมที่ https://www.php.net/manual/en/function.syslog.php

คุณสามารถใช้ method ข้างล่างสำหรับการพิมพ์ข้อความออก I/O streams อื่นๆ
$out = fopen('php://stdout', 'w'); //output handler
fputs($out, $str); //writing output operation
fclose($out); //closing handler
โดยที่ php://stdout สามารถแทนด้วย php://stderr หรือ php://output
อ่านข้อมูลเพิ่มเติมที่ https://www.php.net/manual/en/wrappers.php.php