How do we get my UNIT(service) name in unit.sevice
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm not sure I follow you, but I do note that you have two 'Type=' directives. You need to be clear about which type you're after. The 'ExecStart=' entry must consist of one command (eg path to an executable shell script).
Actual implementation is, i have the case where my executable will be installed in different directory. Let's say executable is "MyExe" and installed in "mypath"
I will be creating on service script like below and i will keep service name like "MyExe.script",
[Unit]
Description=PLIN_SSP_01
[Service]
Type=simple
User=root
Type=forking
Environment="install_dir=mypath"
ExecStart=${install_dir}/{Here i need service script name}'
Restart=always
In this way, always executable and script name will always remains same.
Please give your input on this if this is achievable?
Regards,
Boobalan M
Last edited by Boobalan M; 01-23-2018 at 02:12 AM.
Actual query is, my intention is not configure executable name inside script also. Instead, when ever i run "systemctl start MyExe" script should detect that "MyExe" the is executable to be executed(from install directory).
We do not wanted to configure executable inside script also instead will expose like executable and script name are same.
Now I think I understand I think what you're after are template unit files in the form <service_name>@<script_name>.service, whereby service instances can be created dynamically as needed. Such a template service could be constructed such that a script called <script_name> can be executed when the given service instance is started.
Not exactly this way i was expecting as i could see that here we need to make our script naming convention like "MyExe@MyExe.service" instead "MyExe.service". Any i will go forward with this option.
Also i could see that, i couldnt use env variable in "WorkingDirectory" inside script.
Environment="INSTALL_DIR=/opt/product/mypath"
WorkingDirectory=${INSTALL_DIR}/bin
I could see that path expansion not working in WorkingDirectory. Is there any way?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.