How to , and other stuff about linux, photo, php … A linux, photography blog. To remember some linux situation, and fix them quickly.

December 11, 2017

Redis can’t save in background

Filed under: Linux — Tags: , , — admin @ 10:53 am

Well I see something in log

[3765] 30 Jan 11:31:10 * 1 changes in 900 seconds. Saving…
[3765] 30 Jan 11:31:10 # Can’t save in background: fork: Cannot allocate memory

To fix this redis error you need to

echo 1 > /proc/sys/vm/overcommit_memory sysctl vm.overcommit_memory=1

 

December 8, 2017

centos 7 systemctl restart httpd or other service take long time

Filed under: Linux — Tags: , , , — admin @ 12:47 pm

Well on centos 7 I notice that when I run systemctl restart httpd sometime take a lot of time  to restart it .

After some search I found out that there is a TimeoutStopSec variable that do something like this

“Configures the time to wait for stop. If a service is asked to stop, but does not terminate in the specified time, it will be terminated forcibly via SIGTERM, and after another timeout of equal duration with SIGKILL (see KillMode= in systemd.kill(5)). Takes a unit-less value in seconds, or a time span value such as “5min 20s”. Pass “infinity” to disable the timeout logic. Defaults to DefaultTimeoutStopSec= from the manager configuration file”

So I modify the

/usr/lib/systemd/system/httpd.service and added the

TimeoutStopSec=5

Into it

You need to run systemctl daemon-reload after modify that file

[Service]

TimeoutStopSec=5

delete large directory containing thousands of files

Filed under: Linux — Tags: , , , , , — admin @ 11:22 am

Well if you try to remove a directory with multiple files rm will take a long time also some load on that server .

One solution is to rsync a empty directory .

mkdir empty_dir
rsync -a –delete empty_dir/ yourdirectory/

Also a perl can be made but the rsync is easy for me to remeber .

Some more information about this you can find here

https://serverfault.com/questions/183821/rm-on-a-directory-with-millions-of-files/328305#328305

 

Powered by WordPress