# Best practice and approach on how to check if the service is started and start if it is not

**URL:** <https://forum.ansible.com/t/best-practice-and-approach-on-how-to-check-if-the-service-is-started-and-start-if-it-is-not/22206>\
**Category:** Ansible Project\
**Created:** [August 3, 2016, 8:09pm UTC](https://forum.ansible.com/t/best-practice-and-approach-on-how-to-check-if-the-service-is-started-and-start-if-it-is-not/22206 "2016-08-03T20:09:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wiggler](https://avatars.discourse-cdn.com/v4/letter/w/a4c791/32.png) [@wiggler](https://forum.ansible.com/u/wiggler)\
**Post date:** [August 3, 2016, 8:09pm UTC](https://forum.ansible.com/t/best-practice-and-approach-on-how-to-check-if-the-service-is-started-and-start-if-it-is-not/22206/1 "2016-08-03T20:09:12Z")

</div>

Hello all,

I would like to automate the checking of the services if is it properly chkconfig on and set to on if its off and start. also need to check if the service is on then start if its off in RHEL6.

Thanks.

---

<div class="post-metadata">

**Author:** ![Bryan\_Pearson](https://avatars.discourse-cdn.com/v4/letter/b/9f8e36/32.png) [@Bryan\_Pearson](https://forum.ansible.com/u/Bryan_Pearson)\
**Post date:** [August 4, 2016, 12:25am UTC](https://forum.ansible.com/t/best-practice-and-approach-on-how-to-check-if-the-service-is-started-and-start-if-it-is-not/22206/2 "2016-08-04T00:25:22Z")

</div>

Hello,

Is there a specific importance to knowing this?  
Ansible can be set to start a process if its not running and also add the chkconfig as needed.

```auto
# Example action to start service httpd, if not running
- service: name=httpd state=started enabled=yes

```

```auto
Should be enough to resolve it for you.

```

```auto

```
