Skip to content

Instantly share code, notes, and snippets.

@bhouse
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhouse/4737034b51e654838d4d to your computer and use it in GitHub Desktop.
Save bhouse/4737034b51e654838d4d to your computer and use it in GitHub Desktop.
chef-client holding on to log file fd
# show that the current chef-client daemon has an open fd on /var/log/chef/client.log
root@master01.rsc:/var/log/chef# date
Thu Jun 19 01:57:11 UTC 2014
root@master01.rsc:/var/log/chef# ps -ef | grep chef
root 3695 1 0 Jun18 ? 00:00:00 /opt/chef/embedded/bin/ruby /usr/bin/chef-client -d -P /var/run/chef/client.pid -c /etc/chef/client.rb -i 1800 -s 300 -f -L /var/log/chef/client.log
root@master01.rsc:/var/log/chef# ls -li client.log
12573070 -rw-r--r-- 1 root root 62908189 2014-06-19 01:38 client.log
root@master01.rsc:/var/log/chef# lsof client.log
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
chef-clie 3695 root 6w REG 202,1 62908189 12573070 client.log
# moving client.log to client.log.moved, and the daemon still has the open fd on it
root@master01.rsc:/var/log/chef# mv client.log{,.moved}
root@master01.rsc:/var/log/chef# lsof client.log.moved
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
chef-clie 3695 root 6w REG 202,1 62908189 12573070 client.log.moved
root@master01.rsc:/var/log/chef# lsof -p 3695 | grep client.log
chef-clie 3695 root 6w REG 202,1 62908189 12573070 /var/log/chef/client.log.moved
# send HUP to the chef-client daemon, it opens a new fd on client.log, but keeps open the fd on client.log.moved
root@master01.rsc:/var/log/chef# kill -HUP 3695
root@master01.rsc:/var/log/chef# lsof -p 3695 | grep client.log
chef-clie 3695 root 6w REG 202,1 62908254 12573070 /var/log/chef/client.log.moved
chef-clie 3695 root 10w REG 202,1 0 12568205 /var/log/chef/client.log
root@master01.rsc:/var/log/chef# lsof client.log
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
chef-clie 3695 root 10w REG 202,1 0 12568205 client.log
root@master01.rsc:/var/log/chef# lsof client.log.moved
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
chef-clie 3695 root 6w REG 202,1 62908254 12573070 client.log.moved
root@master01.rsc:/var/log/chef# chef-client --version
Chef: 11.12.8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment