Skip to main content

Write Search Path

MOVED TO RUNDECK!!!

 

This script's role is to copy the paths of subfolders located in the \10.60.0.49\Mernokok\02 - Creo config\04 - Catalog\02 - Kereskedelmi directory to the file located at \10.60.0.49\Mernokok\06 - Creo\12 - Misc config\search.pro, so that Creo can locate the commercial items.

Python Script (list_paths.py) (/opt/WriteSearchpath)

This Python script is designed to perform a specific task: listing all files and directories within a specified directory, modifying their paths to a new format, ensuring no duplicates, sorting them alphabetically, and then writing these paths to a specified output file. It's the core logic of what you want to accomplish.

Bash Script (run_WriteSearchpath.sh) (/opt/WriteSearchpath)

This Bash script serves as a wrapper or launcher for your Python script. Its purpose is to execute the Python script. The presence of this Bash script suggests a need or preference for invoking the Python script through a shell environment, possibly to ensure the correct execution environment or to simplify the command needed to run the Python script.

Systemd Service File (WriteSearchpath.service) (/etc/systemd/system)

This service file defines a systemd service named WriteSearchpath. Systemd is a system and service manager for Linux operating systems, and service units allow you to define how to manage services or applications. The key elements here are:

  • Description: Provides a human-readable name or description of the service.

  • Type: Specifies the service type; oneshot indicates that the process is expected to run to completion and then stop.

  • ExecStart: Defines the command to execute when the service starts, which in this case is your Bash script that runs the Python script.

This service is directly linked to the Bash script by the ExecStart parameter, which tells the service to execute your Bash script when the service is started.

Systemd Timer File (WriteSearchpath.timer) (/etc/systemd/system)

The timer file is used to schedule the execution of the systemd service at regular intervals or specific times. It's essentially a timer or alarm that triggers the service. The key elements are:

  • OnCalendar: Specifies when the timer should trigger. In your case, it's set to run daily at 7:00 AM.

  • Persistent: Ensures that the timer will trigger the service even if the event was missed (e.g., if the system was down at the scheduled time).

The timer is linked to the service unit by its name. Systemd uses the base name of the timer (in this case, WriteSearchpath) to determine which service to start when the timer triggers. Therefore, WriteSearchpath.timer is designed to trigger WriteSearchpath.service.

The [Install] section with WantedBy=timers.target ensures that the timer is enabled to start automatically at boot if it's enabled (using systemctl enable WriteSearchpath.timer).

Summary of How They Work Together

  1. Python Script: Contains the logic for listing and writing file paths.

  2. Bash Script: Serves as an intermediary to run the Python script.

  3. Systemd Service: Defines how to start the Bash script (and therefore the Python script) as a service.

  4. Systemd Timer: Schedules the service to run at a specific time, effectively linking time-based execution to your script.

Notes

Useful Commands:

  • sudo systemctl list-timers