# Linux service is not started by when run by Chef but starts fine when run manually

**URL:** <https://discourse.chef.io/t/linux-service-is-not-started-by-when-run-by-chef-but-starts-fine-when-run-manually/7578>\
**Category:** Chef Infra (archive)\
**Created:** [January 11, 2016, 10:57am UTC](https://discourse.chef.io/t/linux-service-is-not-started-by-when-run-by-chef-but-starts-fine-when-run-manually/7578 "2016-01-11T10:57:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel.amadei](https://avatars.discourse-cdn.com/v4/letter/d/a183cd/32.png) [@daniel.amadei](https://discourse.chef.io/u/daniel.amadei)\
**Post date:** [January 11, 2016, 10:57am UTC](https://discourse.chef.io/t/linux-service-is-not-started-by-when-run-by-chef-but-starts-fine-when-run-manually/7578/1 "2016-01-11T10:57:49Z")

</div>

Hi all,

I’ve created a service to be started on node boot. I’m using CentOs 6.7 and if I start my service manually via service start it starts fine.

However when running via Chef the service is not started but I see the command to start it was run as there are some echo messages that I can see on Chef logs.

My start script has to change the user and to daemonize itself. This is the script I’m using but I’ve also tried su and sudo.

start() {  
ulimit -n 65535  
[-x startExec] || exit 5 echo -n "Starting $prog: . Command $startExec. User: \<%=node[:wls][:user][:name]%\>"  
daemon --user \<%=node[:wls][:user][:name]%\> "startExec" retval=?  
echo -n $"RETVAL = $retval"  
echo  
return $retval  
}

Any ideas?

Thanks,  
Daniel

---

<div class="post-metadata">

**Author:** ![yoshiwaan](https://avatars.discourse-cdn.com/v4/letter/y/ba9def/32.png) [@yoshiwaan](https://discourse.chef.io/u/yoshiwaan)\
**Post date:** [January 11, 2016, 6:52pm UTC](https://discourse.chef.io/t/linux-service-is-not-started-by-when-run-by-chef-but-starts-fine-when-run-manually/7578/2 "2016-01-11T18:52:35Z")

</div>

There was a similar (although not answered) discussion here:

> [@Unable to start apache service in redhat](https://discourse.chef.io/t/unable-to-start-apache-service-in-redhat/7572):
>
> I have written script to start apache server function start() { if [-z “${apache\_running}”] ; then echo "Apache is not running" echo "Starting Apache Tomcat" cd /opt/apache-tomcat-7.0.64/bin/ sudo ./startup.sh else return 0; fi } it is working fine in ubuntu, centos but it is unable to start the service in redhat and is not showing any error during the run and specifying starting tomcat everytime I run the client. But I was able to start the service with the following command serv…

If you're using an older version of the varnish cookbook I know a buggy  
monkey patch caused service detection failure to break
