I want to create a systemd service that starts N identical copies of a process (as in, same arguments for each copy), and restarts any of them if they crash. It is okay if N is hardcoded in the service file.  Google suggests that templated/instantiated services can do this, but the examples I find are all of the form systemctl start myservice@someid, repeated for each process, which is not what I want. I want to be able to do systemctl start myservice and have it start all processes and keep them alive.  How do I do this correctly?  (I am porting this service from upstart, which requires two files to achieve this effect, one parent instantiating multiple children. That would be okay, albeit not ideal)
122677
At my organization, we have a number of queue consuming worker processes. We're currently using SupervisorD to manage them, but would like to use SystemD if possible for certain advantages therein. I'm fairly experienced with writing custom units, but I don't immediately have an analog in SystemD land for this.  In the  a parameter called numprocs is detailed which allows one to set the number of processes they'd like to be started with the service. If I want 30 processes started, it's a one-line change.  Is there a setting in SystemD units that will allow me to specify how many of these processes I'd like started?
106409
Objective  I want to run this command VBoxManage startvm MyVM --type headless at the boot system just like a service (postgres, apache) does.  What i've tried  1. I've tried to create a service using sc command  I've found over the internet that could be the solution so i tried all this versions:   sc create "vboxMyVMService" binPath= "C:\Progman Files\Oracle\VirtualBox\VBoxManage.exe startvm MyVM --type headless" sc create "vboxMyVMService" binPath= "C:\Progman Files\Oracle\VirtualBox\VBoxManage startvm MyVM --type headless"   No success, so i tried to suppress the verbose output of the command   sc create "vboxMyVMService" binPath= "C:\Progman Files\Oracle\VirtualBox\VBoxManage.exe startvm MyVM --type headless &gt; NUL" sc create "vboxMyVMService" binPath= "C:\Progman Files\Oracle\VirtualBox\VBoxManage startvm MyVM --type headless"   Still no results. All this version returned me a 1053 error. So the last call was to add the Virtualbox command to the Path     sc create "vboxMyVMService" binPath= "VBoxManage.exe startvm MyVM --type headless" sc create "vboxMyVMService" binPath= "VBoxManage startvm MyVM --type headless"   suppressing output   sc create "vboxMyVMService" binPath= "VBoxManage.exe startvm MyVM --type headless &gt; NUL" sc create "vboxMyVMService" binPath= "VBoxManage startvm MyVM --type headless &gt; NUL"   No positive result always 1053 error.  2. Assign Computer Startup Scripts  I followed this  with my last hope, but no success.  What left  I'm thinking about to download the Visual Studio and try something related to .    So guys, where is my mistake? Is there hope to me?    FAQs   Can you switch you OS to linux?   No. It's out of question.  Why you need this VM to startup at with the system?   Unfortunately this windows 7 host is a small server for the application running over the VM. The machine it's not mine and it's the only option they gave to me to make the deploy.  Why you are not making the deploy of the application inside the windows host?   I'm not running PHP, or any .NET stuff, so no.
73133
My computer booted to a black screen with this error message.  Welcome to emergency mode! After logging in,type "journalctl -xb" to view    system logs, "systemctl reboot" to reboot, "systemctl default" or ^D to    try again to boot into default mode.   journalctl -xb snippet (what I think is wrong):  -- Unit systemd-fsckd.service has begun starting up. juli 09 15:40:16 kim-SSD-Sationary systemd-fsck[414]: /dev/sdb1 contains a file system with errors, check forced. juli 09 15:40:16 kim-SSD-Sationary systemd-fsck[414]: /dev/sdb1: Inodes that were part of a corrupted orphan linked list found. juli 09 15:40:16 kim-SSD-Sationary systemd-fsck[414]: /dev/sdb1: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY. juli 09 15:40:16 kim-SSD-Sationary systemd-fsck[414]: (i.e., without -a or -p options) juli 09 15:40:16 kim-SSD-Sationary systemd-fsck[414]: fsck failed with error code 4. juli 09 15:40:16 kim-SSD-Sationary systemd-fsck[414]: Running request emergency.target/start/replace juli 09 15:40:16 kim-SSD-Sationary systemd[1]: systemd-fsck-root.service: main process exited, code=exited, status=1/FAILURE juli 09 15:40:16 kim-SSD-Sationary systemd[1]: Failed to start File System Check on Root Device. -- Subject: Unit systemd-fsck-root.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel --  -- Unit systemd-fsck-root.service has failed. --  -- The result is failed. juli 09 15:40:16 kim-SSD-Sationary systemd[1]: Unit systemd-fsck-root.service entered failed state. juli 09 15:40:16 kim-SSD-Sationary systemd[1]: systemd-fsck-root.service failed. juli 09 15:40:16 kim-SSD-Sationary systemd[1]: Starting Remount Root and Kernel File Systems... -- Subject: Unit systemd-remount-fs.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel   I ignored other errors like: ACPI PCC probe failed, nvidia not proprietary, etc.  I can access my PC by pressing Ctrl+D , but it is annoying.
3529
I have a systemd file to start a jar file. But I want to execute jar file as *.jar. Is there a way to do this?   [Unit] Description=Test Background  [Service] ExecStart=/usr/bin/java -jar /var/www/test.com/*.jar Type=simple WorkingDirectory=/var/www/test.com  [Install] WantedBy=multi-user.target   I tried this but not working.
66251
Why do PIDS under Linux (generally) increment by 4? The only exception I can think of is startup processes run by systemd, which increment by 1 when they are related or 2 otherwise.  How was the number 4 chosen as the default, and is it changeable?
97611
I am having trouble getting named to start using systemd on the Fedora 18 Raspberry Pi spin. It starts, then a few moments later there is a timeout and it fails. If I run the commands in named.service by hand, named starts just fine. I don't know what the timeout is that systemctl is looking for or where it is being invoked. I have read the man pages for systemctl, systemd and others and I will continue to research this, but if anyone has any pointers, that would be great.   systemctl status named.service output:  named.service - Berkeley Internet Name Domain (DNS)           Loaded: loaded (/usr/lib/systemd/system/named.service; disabled)           Active: failed (Result: timeout) since Tue 2013-01-29 14:36:41 EST; 35min ago          Process: 4189 ExecStart=/usr/sbin/named -u named $OPTIONS (code=exited, status=0/SUCCESS)          Process: 4186 ExecStartPre=/usr/sbin/named-checkconf -z /etc/named.conf (code=exited, status=0/SUCCESS)          Process: 4183 ExecStartPre=/usr/libexec/generate-rndc-key.sh (code=exited, status=0/SUCCESS)  Jan 29 14:35:12 raspi.example.com named[4191]: all zones loaded Jan 29 14:35:12 raspi.example.com systemd[1]: PID file /run/named/named.pid not readable (yet?) after start. Jan 29 14:35:12 raspi.example.com named[4191]: running Jan 29 14:36:41 raspi.example.com systemd[1]: named.service operation timed out. Terminating. Jan 29 14:36:41 raspi.example.com named[4191]: shutting down Jan 29 14:36:41 raspi.example.com named[4191]: stopping command channel on 127.0.0.1#953 Jan 29 14:36:41 raspi.example.com named[4191]: no longer listening on 127.0.0.1#53 Jan 29 14:36:41 raspi.example.com named[4191]: exiting Jan 29 14:36:41 raspi.example.com systemd[1]: Failed to start Berkeley Internet Name Domain (DNS). Jan 29 14:36:41 raspi.example.com systemd[1]: Unit named.service entered failed state     The named.service file  [Unit] Description=Berkeley Internet Name Domain (DNS) Wants=nss-lookup.target Before=nss-lookup.target After=network.target  [Service] Type=forking EnvironmentFile=-/etc/sysconfig/named Environment=KRB5_KTNAME=/etc/named.keytab PIDFile=/run/named/named.pid ExecStartPre=/usr/libexec/generate-rndc-key.sh ExecStartPre=/usr/sbin/named-checkconf -z /etc/named.conf ExecStart=/usr/sbin/named -u named $OPTIONS ExecReload=/bin/sh -c '/usr/sbin/rndc reload &gt; /dev/null 2&gt;&amp;1 || /bin/kill -HUP $MAINPID' ExecStop=/bin/sh -c '/usr/sbin/rndc stop &gt; /dev/null 2&gt;&amp;1 || /bin/kill -TERM $MAINPID' PrivateTmp=true [Install] WantedBy=multi-user.target
99042
I am currently writing a little bootstrap code for a service that can be run in the console. It essentially boils down to calling the OnStart() method instead of using the ServiceBase to start and stop the service (because it doesn't run the application if it isn't installed as a service and makes debugging a nightmare).  Right now I am using Debugger.IsAttached to determine if I should use ServiceBase.Run or [service].OnStart, but I know that isn't the best idea because some times end users want to run the service in a console (to see the output etc. realtime).  Any ideas on how I could determine if the Windows service controller started 'me', or if the user started 'me' in the console? Apparantly  is not the answer. I thought about using commandline args, but that seems 'dirty'.  I could always see about a try-catch statement around ServiceBase.Run, but that seems dirty. Edit: Try catch doesn't work.  I have a solution: putting it up here for all the other interested stackers:      public void Run()     {         if (Debugger.IsAttached || Environment.GetCommandLineArgs().Contains&lt;string&gt;("-console"))         {             RunAllServices();         }         else         {             try             {                 string temp = Console.Title;                 ServiceBase.Run((ServiceBase[])ComponentsToRun);             }             catch             {                 RunAllServices();             }         }     } // void Run      private void RunAllServices()     {         foreach (ConsoleService component in ComponentsToRun)         {             component.Start();         }         WaitForCTRLC();         foreach (ConsoleService component in ComponentsToRun)         {             component.Stop();         }     }   EDIT: There was another question on StackOverflow where the guy had problems with the Environment.CurrentDirectory being "C:\Windows\System32" looks like that may be the answer. I will test today.
119489
I have a service application built in Delphi that works great.  It does exactly what I want it to do and all is happy.  All is fine until I want to run two (or more) instances of that service on a single machine.  Since the service name is hard coded into the program (via the Name property of the service), I can only install the service once on any given computer.  If I try to modify the Name property at run-time, the service does not respond unless the Name property is set to the same thing that was set during design time.  I have done a workaround for this where I have all of the code that is not interacting directly with the service control manager encapsulated out into separate unit(s).  Then I write a separate Delphi project for each instance that I want of the service that has just enough code to launch itself and start running the main code.  This method is, in my opinion, ugly and is certainly inefficient.  It works okay for two instances, but then we need a third and a fourth and ...  Is there any way that I can modify my code so that I have just one Delphi project that can install and run itself as multiple service instances with some simple run-time input (e.g. command line flag)?  Or perhaps a broader question: Is there a "right way" to accomplish goal?
53863
This works perfectly:  $ inotifywait --event create ~/foo Setting up watches. Watches established. /home/ron/foo/ CREATE bar   However, this just sits there when directory tun0 is created under /sys/devices/virtual/net.  $ inotifywait --event create /sys/devices/virtual/net Setting up watches. Watches established.   Since those folders are world readable, I'd expect inotifywait to work.  So, what am I doing wrong?  Thanks
96068
The UNIX system call for process creation, fork(), creates a child process by copying the parent process.  My understanding is that this is almost always followed by a call to exec() to replace the child process' memory space (including text segment).  Copying the parent's memory space in fork() always seemed wasteful to me (although I realize the waste can be minimized by making the memory segments copy-on-write so only pointers are copied).  Anyway, does anyone know why this duplication approach is required for process creation?
49950
I need to write robust code in .NET to enable a windows service (server 2003) to restart itself. What is the best way to so this? Is there some .NET API to do it?
29528
So, I have 10 CPU core and 20 data to process. I want to process the data in parallel but I am afraid if I just process 20 at once it will make some problem. So, I want to process 10 data 2 times. Is there any command to do this?  Add info:  The data are in file format. It is quite huge, per file can reach 10GB. In my expreience if I launch more than 10 process, the PC will become really slow and even lag. So I am limiting the process to be only 10 which is equal to the number of cores. As for my RAM, I believe the software which process the file will not load everything at once so the RAM usage is quite low. That is why I just need to parallel the process for every 10 data. For now, I generate 10 shell script which execute parallel and each shell script contains sequential command.
81028
I've been following the excellent guides to create debian packages to install an application executable    and using dh-systemd to install a systemd service    however, I would like to combine the two to create a package to install a service and install the binary which gets run by the service.  The first tutorial has the application files in the directory above the /debian folder and a make file to build and install the application, whereas the systemd tutorial has the service file in the debian folder. It is not clear to me how to create a control file which installs both service file and dependant binary.  I'd be grateful if someone could advise how to do this or provide some useful reference material.  I've tried reading  but this doesn't explain much.  Is this a realistic expectation, or should services and applications be packaged separately?  Thanks
99758
I created a systemd file unit (Centos 7) and I wanted to save the Python output to a file but the service won't start with the below code.  [root@static ~]# cat /etc/systemd/system/pykms.service [Unit] Description=PY-KMS After=network.target  [Service] Type=simple User=root ExecStart=/usr/bin/python2.7 /usr/local/py-kms-master/server.py 192.168.1.100 1688 -v &gt; /usr/local/py-kms-master/pykmsss.log    [Install] WantedBy=multi-user.target   NOTE: if I delete the line after ">" above, then everything works fine but I want to save the logs to a file.  systemctl status pykms -l   [root@static ~]# systemctl status pykms -l pykms.service - PY-KMS    Loaded: loaded (/etc/systemd/system/pykms.service; enabled)    Active: active (running) since Tue 2015-11-24 20:54:28 IRST; 2s ago  Main PID: 2788 (server.py)    CGroup: /system.slice/pykms.service            └─2788 /usr/bin/python2.7 /usr/local/py-kms-master/server.py 192.168.1.100 1688 -v  Nov 24 20:54:28 server.de systemd[1]: Starting PY-KMS... Nov 24 20:54:28 -server.de systemd[1]: Started PY-KMS.
66272
I'm a web developer. When I want to start working, always i'm executing some command on terminal. For example:  sudo service apache2 start sudo service mysql start sublime   For speed up this process, I create a .sh file which contain these commands.   Now, when I want to start working, I'm just executing this .sh file and all services (mysql, apache2 etc.) starting.   Is it possible to create a custom command for this? For example if I type sudo start-working to terminal, it will execute these commands
39337
I have a script that I would like to run as a service on my Ubuntu Server 11.04 headless box. That is, I want to have the correct files under /etc/init.d/ and to be able to control it via the service command.  Is there any guide available that will show me how to do this?
73541
I have a list/queue of 200 commands that I need to run in a shell on a Linux server.   I only want to have a maximum of 10 processes running (from the queue) at once. Some processes will take a few seconds to complete, other processes will take much longer.   When a process finishes I want the next command to be "popped" from the queue and executed.  Does anyone have code to solve this problem?  Further elaboration:  There's 200 pieces of work that need to be done, in a queue of some sort. I want to have at most 10 pieces of work going on at once. When a thread finishes a piece of work it should ask the queue for the next piece of work. If there's no more work in the queue, the thread should die. When all the threads have died it means all the work has been done.  The actual problem I'm trying to solve is using imapsync to synchronize 200 mailboxes from an old mail server to a new mail server. Some users have large mailboxes and take a long time tto sync, others have very small mailboxes and sync quickly.