=== Guest62484 is now known as rcj | ||
arksi | does anybody have suggestions on how to detatch and run in background a command through runcmd? | 20:21 |
---|---|---|
harmw | nohup or cmd & | 20:21 |
smoser | arksi, is cloud-init waiting if you use & ? | 20:22 |
smoser | runcmd: | 20:22 |
smoser | [ sh, -c, 'mycommand >/var/log/mycommand.log 2>&1 </dev/null &' ] | 20:22 |
smoser | something to that effect | 20:22 |
arksi | thanks | 20:23 |
arksi | I will find out if it waits | 20:23 |
arksi | I was trying | 20:23 |
arksi | [ setsid, program, & ] | 20:24 |
smoser | arksi, well that will probably just fail | 20:27 |
arksi | It does ;) | 20:27 |
smoser | as it will try to execute 'setsid' with the arguments: 'program' and '&' | 20:27 |
arksi | I will try your recommendation and see how it goes | 20:27 |
arksi | right | 20:27 |
smoser | if you just quote it, it will pass it to shell | 20:28 |
arksi | I didn't know we could use hardquotes like that | 20:28 |
arksi | right | 20:28 |
arksi | makes sense | 20:28 |
arksi | good idea | 20:28 |
smoser | ie, if the entry is a string it passes to shell | 20:28 |
arksi | I will let you know how it works | 20:28 |
arksi | right | 20:28 |
arksi | [ /bin/sh, -c , ... ] | 20:28 |
arksi | is clever | 20:28 |
arksi | thanks a lot | 20:28 |
smoser | just to be cleare, above: | 20:28 |
smoser | runcmd: | 20:28 |
arksi | Right | 20:28 |
smoser | - "setsid program &" | 20:29 |
smoser | - "another program" | 20:29 |
arksi | Does runcmd spawn a subshell? | 20:29 |
smoser | will do what you want. invoking sh -c 'setsid program' | 20:29 |
arksi | spawn subshell and exec? | 20:29 |
arksi | right | 20:29 |
smoser | if its a string, it goes to shell | 20:29 |
smoser | if its an array, no shell | 20:29 |
arksi | ah | 20:29 |
arksi | so it is equivalent to invoking system() if it is an array? | 20:30 |
smoser | generally speaking i hate passing things to shell | 20:30 |
smoser | :) | 20:30 |
arksi | same heh | 20:30 |
smoser | i would have though tsystem would go to a shell | 20:31 |
arksi | you are right | 20:32 |
arksi | system() invokes the shell and executes as a separate process | 20:32 |
arksi | exec() family replaces the current process with the program being exec'd | 20:33 |
arksi | system() = fork(), execve() and wait() | 20:33 |
arksi | I have to run a stupid program that checks for runlevel heh | 20:34 |
arksi | while cloud-init is running (on CentOS 7, at least), if you invoke runlevel command it reports 'unknown' | 20:35 |
arksi | (why anybody in this century is still checking runlevels is a mystery to me...) | 20:35 |
arksi | so I cannot invoke this program directly through cloud-init, hence I am trying to get it to detatch from init process and run in the background after waiting for runlevel 3 | 20:36 |
arksi | horrible stuff :) | 20:36 |
Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!