0

I am trying to execute a shell script on RHEL7.1 when the machine starts. As in ubuntu, Upstart scripts (in /etc/init/) are used to execute any scripts or to start any services at boot time, is there anything equivalent in RHEL 7.1 to upstart?

user3460393
  • 21
  • 3
  • 6

2 Answers2

1

Let's say you want to execute example.service at booting time, you'd do:

vi /etc/systemd/system/example.service

with this content:

 [Unit] 
 Description=Example 
 After=network.target 

 [Service] 
 Type=simple 
 WorkingDirectory=/var/lib/example
 ExecStart=/usr/local/bin/example --pid /var/run/example.pid --core unlimited -c /etc/example/example.ini 
 Restart=always 
 User=root
 Group=root 
 LimitNOFILE=10240 
 LimitFSIZE=infinity

 [Install] 
 WantedBy=multi-user.target

Then, just start and enable it:

systemctl start example.service
systemctl enable example.service
jordanm
  • 889
  • 5
  • 9
sysfiend
  • 1,387
  • 1
  • 12
  • 24
-1

Add the scrpit in /etc/rc.d/rc.local file, The script will be automatically executed during boot.

BDRSuite
  • 400
  • 1
  • 9