Skip to end of metadata
Go to start of metadata

When you need to add some text strings to a certain text file, the common approach is to open file in append mode, write additional strings, and close that file. PHP provides a straightforward and simple function can do that by one function.

$txt = date("Y-m-d H:i:s") . ": service process does not exist\n";
$myfile = file_put_contents('logs.txt', $txt.PHP_EOL , FILE_APPEND | LOCK_EX);

Above snippet is a part of my code to manage my linux server.