Skip to content

How to spawn slow / background commands from cf-agent? #4504

Answered by nickanderson
olehermanse asked this question in Q&A
Discussion options

You must be logged in to vote

Alternatively, you can detach the commands from the agent run, but if you do this cf-agent won't be tracking anything at all about the result of the commands.
For that, there is a daemonize bundle in the stdlib you may find helpful.

exec 2>&1
cf-locate daemonize | head 1
cf-locate -f -p daemonize
:


bundle agent daemonize(command)
# @brief Run a command as a daemon. I.e., fully detaches from Cfengine.
# @param command The command to run detached
# Note: There will be no output from the command reported by cf-agent. This
# bundle has no effect on windows
#
# **Example:**
# ```cf3
# methods:
#   "Launch Daemon"
#     usebundle => daemonize("/bin/sleep 30");
# ```
{
  commands:
    !windows…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@olehermanse
Comment options

olehermanse Feb 12, 2021
Maintainer Author

Answer selected by olehermanse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants