User story #10313
closedRun a command just once
Description
I know this is not the intended use of configuration management, but I had unexpected behavior in a directive (the /tmp directory was unexpectedly renamed) and I needed to fix it.
I tried using the job scheduler with a priority of zero and thought that would do it but I couldn't seem to get it to work or didn't wait long enough since it only gives me two hourly boundaries. I ended up adding a rule for a cron job to do the rename, then deleting the rule after the job ran, then put in another rule to delete the cron job entry in the /etc/cron.d directory, then deleted that rule.
Updated by Alexis Mousset over 7 years ago
Depending on the goal of the command to execute, it is better to test the result directly, for example, in the technique editor:
- a method "Directory check exists" on
/wrong_tmp_dir
- a method "Command Execution" with a condition on the outcome of the previous method
You could always use a file as a flag if you cannot test if the command was executed:
- a method "File check exists" on for example
/var/rudder/flag_file
- a method "Command Execution" with a condition on the outcome of the previous method
- a method "File create" on
/var/rudder/flag_file
Does this answer your question?
Updated by Hamlyn Mootoo over 7 years ago
Well I was just really looking for an existing directive that would just perform a one-off shell command that I could link to a rule which I could subsequently delete after the command completed. I tried using the job scheduler in this capacity, but I'm not sure how it's supposed to work, as I was unable to get it to execute the command I gave it.
Updated by Vincent MEMBRÉ over 7 years ago
- Target version changed from 4.1.0~rc1 to 4.1.0
Updated by François ARMAND over 7 years ago
- Category changed from Server components to Techniques
Updated by Vincent MEMBRÉ over 7 years ago
- Target version changed from 4.1.0 to 4.1.1
Updated by Vincent MEMBRÉ over 7 years ago
- Target version changed from 4.1.1 to 4.1.2
Updated by Vincent MEMBRÉ over 7 years ago
- Target version changed from 4.1.2 to 4.1.3
Updated by Vincent MEMBRÉ over 7 years ago
- Target version changed from 4.1.3 to 4.1.4
Updated by Benoît PECCATTE over 7 years ago
- Status changed from New to Discussion
The scheduler was made to run a command about once a day or once a week, at a predefined random time (like what we do for inventories).
This is not the best use case for Rudder, but if you want to do it anyway, you can create a technique the :- Call the method: File create ("/tmp/a file")
- On condition: file_create__tmp_a_file_repaired
- Call Command execution("your command")
Please note that if the file if remove, the command may be re-executed again.
However it can do the trick for your problem.
Updated by Vincent MEMBRÉ over 7 years ago
- Target version changed from 4.1.4 to 4.1.5
Updated by Alexis Mousset over 7 years ago
- Target version changed from 4.1.5 to 4.1.6
Updated by Vincent MEMBRÉ over 7 years ago
- Target version changed from 4.1.6 to 4.1.7
Updated by Vincent MEMBRÉ about 7 years ago
- Target version changed from 4.1.7 to 4.1.8
Updated by Vincent MEMBRÉ about 7 years ago
- Target version changed from 4.1.8 to 4.1.9
Updated by Vincent MEMBRÉ almost 7 years ago
- Target version changed from 4.1.9 to 4.1.10
Updated by Benoît PECCATTE almost 7 years ago
- Tracker changed from Question to User story
- Target version changed from 4.1.10 to Ideas (not version specific)
Converting to a user story since this should be a feature in ncf (for example based on flags).
Updated by Benoît PECCATTE almost 7 years ago
- Subject changed from Is there a way to run a command just once? to Run a command just once
Updated by Alexis Mousset over 5 years ago
- Status changed from Discussion to Rejected
We did it in #13667
Updated by Alexis Mousset over 5 years ago
- Is duplicate of User story #13667: Add condition_once and execute_once generic methods added