Project

General

Profile

Actions

User story #10313

closed

Run a command just once

Added by Hamlyn Mootoo over 7 years ago. Updated over 5 years ago.

Status:
Rejected
Priority:
N/A
Assignee:
-
Category:
Techniques
UX impact:
Suggestion strength:
User visibility:
Effort required:
Name check:
Fix check:
Regression:

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.


Related issues 1 (0 open1 closed)

Is duplicate of Rudder - User story #13667: Add condition_once and execute_once generic methodsReleasedNicolas CHARLESActions
Actions #1

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?

Actions #2

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.

Actions #3

Updated by Vincent MEMBRÉ over 7 years ago

  • Target version changed from 4.1.0~rc1 to 4.1.0
Actions #4

Updated by François ARMAND over 7 years ago

  • Category changed from Server components to Techniques
Actions #5

Updated by Vincent MEMBRÉ over 7 years ago

  • Target version changed from 4.1.0 to 4.1.1
Actions #6

Updated by Vincent MEMBRÉ over 7 years ago

  • Target version changed from 4.1.1 to 4.1.2
Actions #7

Updated by Vincent MEMBRÉ over 7 years ago

  • Target version changed from 4.1.2 to 4.1.3
Actions #8

Updated by Vincent MEMBRÉ over 7 years ago

  • Target version changed from 4.1.3 to 4.1.4
Actions #9

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.

Actions #10

Updated by Vincent MEMBRÉ over 7 years ago

  • Target version changed from 4.1.4 to 4.1.5
Actions #11

Updated by Alexis Mousset over 7 years ago

  • Target version changed from 4.1.5 to 4.1.6
Actions #12

Updated by Vincent MEMBRÉ over 7 years ago

  • Target version changed from 4.1.6 to 4.1.7
Actions #13

Updated by Vincent MEMBRÉ about 7 years ago

  • Target version changed from 4.1.7 to 4.1.8
Actions #14

Updated by Vincent MEMBRÉ about 7 years ago

  • Target version changed from 4.1.8 to 4.1.9
Actions #15

Updated by Vincent MEMBRÉ almost 7 years ago

  • Target version changed from 4.1.9 to 4.1.10
Actions #16

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).

Actions #17

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
Actions #18

Updated by Alexis Mousset over 5 years ago

  • Status changed from Discussion to Rejected

We did it in #13667

Actions #19

Updated by Alexis Mousset over 5 years ago

  • Is duplicate of User story #13667: Add condition_once and execute_once generic methods added
Actions

Also available in: Atom PDF