How to create custom options of my own in systemctl Linux?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users How to create custom options of my own in systemctl Linux?
# 1  
Old 07-07-2019
How to create custom options of my own in systemctl Linux?

Hello All,

Greetings!!

I was trying to create a custom option in systemctl like its out of the box options eg--> status, stop, start, restart, I have tried searching in google but didn't find anything related to it.

Basically I would like to create a custom option which is related to application like:
Code:
sudo systemctl app-activity service_name

Anyone have any thought is greatly welcomed and appreciated here.

Thanks,
R. Singh
# 2  
Old 07-07-2019
As a core RedHat example, you can follow the directions in this link:

10.6. CREATING AND MODIFYING SYSTEMD UNIT FILES

Code:
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sect-managing_services_with_systemd-unit_files

# 3  
Old 07-07-2019
Quote:
Originally Posted by Neo
As a core RedHat example, you can follow the directions in this link:
10.6. CREATING AND MODIFYING SYSTEMD UNIT FILES
Code:
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sect-managing_services_with_systemd-unit_files

Hello Neo,

Thank you for sharing the link, I am aware of creating systemd scripts with multiple options; I had created multiple of them. My question is related to options while running them. Like we have 4 major options which we can use with systemctl eg--> start, stop, status and restart. My query is how could I make a new/custom option related to my application? (For example clear cache of do some operations with this new option, I know I can call my python script inside systemd script to perform operations but thing is how to make a new option of it?) I hope I am clear now Neo.

Thanks,
R. Singh
# 4  
Old 07-07-2019
Hi Ravinder,

Will look more carefully when I am back at my desk. Now I am up country in Thailand near Laos in the green forests with slow Internet on mobile.

In the meantime, maybe someone who works as a Linux sys admin can assist?
This User Gave Thanks to Neo For This Post:
# 5  
Old 07-07-2019
I'm not at all sure that you can create a new option to systemctl and I've never attempted it in all my time working on kernel internals.

However, there are a vast number of things you can do with systemctl on a typical Linux distribution to make managing your applications easier. I guess that you know that there are a great number of options other that the 4 you list: status, start, stop & restart on a typical systemctl implementation.

You can edit the actions of options to address what you want to happen to your applications management.

I'm not even sure that what I've written here is any help to you at all!!! Perhaps you could elaborate on detail.

Refs:
How To Use Systemctl to Manage Systemd Services and Units | DigitalOcean
Understanding Systemd Units and Unit Files | DigitalOcean
# 6  
Old 07-07-2019
I do not think init system is a place for such application features.
You can customize execution of code on those actions but .. your application should implement socket / network / database interface to add functionality or operation during runtime ?

Do you require a daemon type application doing stuff generally and occasionally execute some other code path on user input ?

Regards
Peasant.
# 7  
Old 07-07-2019
Thank you Peasant and Dennis for your replies. I have created systemctl scripts(which are eg--> stop, start applications, call specific python, shell, perl programs in them too). So lets say 1 of the script is doing restart of app along with cleaning its cache too so in spite of going by sudo systemctl start/stop/restart service_name I want to have custom operation name like sudo systemctl restart-with-cache-clean service_name etc so that we can differentiate between 2 operations one which is simple restart and one which has clear cache in it. I hope this is clear now; I have got good expereience in creating systemd scripts now, so no question how to create them as of now Smilie

Will be grateful to you folks if you could guide in this one, cheers.

Thanks,
R. Singh
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to create a TAR File in a Custom Destination Directory?

I want to create the tarzip file into a destination directory, i am in /var/sftp/home/archive/rquadri directory and i am using below command. However it is creating the file in the /var/sftp/home/archive/rquadri directory itself instead of /tmp, may i please know how do i resolve this. tar -cvzf... (5 Replies)
Discussion started by: Ariean
5 Replies

2. UNIX for Advanced & Expert Users

Creating a Custom ISO with Options

Here is the scenario: At work I have been ask to create a custom ISO using UBUNTU as the chosen distro, install our prerequisted packages and present the customer with a choice of options of enabling and disabling services and just in general custom choices that I want to present to the user... (2 Replies)
Discussion started by: metallica1973
2 Replies

3. Infrastructure Monitoring

Nagios widgets to create custom GUI

Hi, I need to create a custom GUI for Nagios, as follows: - no logo - including monitoring info (network status overview, host/service details & status) as well as some network google map I'm looking for Nagios widgets that can be easily integrated in our HTML page. Can you suggest if there... (0 Replies)
Discussion started by: CHK
0 Replies

4. Solaris

Create a custom CD boot

I'm doing as the official document of the SUN : www.sun.com/blueprints/1205/819-3731.pdf Who on page 15 / 18, asks to be executed the following command: 3.Combine mboot and pboot into a single file called mboot+pboot.cd. # dd if=/dev/dsk/c1t1d0p0 of=mboot+pboot.cd bs=512 count=2 I try... (6 Replies)
Discussion started by: poyato
6 Replies

5. Programming

How to create a custom GUI

In Unix, is there any way in which I can create a GUI like Realplayer? I mean the Windows Look & Feel. Borded with buttons, windows, dialogs and other predefined widgets, I am wondering how to create my own buttons that come in different shapes and fashions or even draw images/control objects... (2 Replies)
Discussion started by: hirosima
2 Replies

6. AIX

how to create custom fortunes.dat

How do I create my own custom fortunes.dat on aix? (0 Replies)
Discussion started by: techuser
0 Replies
Login or Register to Ask a Question