Skip to main content
Skip table of contents

Setting Up Batch Run

Note

  • In PLANTA Project, the so-called Headless Client is used to create a batch job.

Step 1: Create a User in PLANTA project

Procedure

  • Create a user (e.g. BATCH) with the following settings in the Users module.
    • Password (you may have to click on the Reset password button)
    • Maximum rights:
      • Can delete actual postings=
      • Object access = *
      • Resource access = *
      • Object rights = 2
    • Menu
    • Role
  • Start the PLANTA project client.
  • Log on with the recently created user.
  • Define a new password.

Step 2: Create/Install a Macro with the Required Functionality

Procedure

  • Create a new module in the Modules module.
  • Adjust Python macro for the intended purpose.
  • For the batch user, this module can be defined as Startup macro which is run every time this user logs on.
    • Alternatively, you can specify the module ID in the start script of the headless client in the PLANTA_MODULE parameter (see here)..

Step 3: Start the Headless Client Manually in Order to Create the Password File

Procedure

  • Open template
    • Note: this command, as well as its following examples, are single-rowed and may only be split for readability purposes:

<Python interpreter> <Headless path>planta_headless.py --service=<Server>:<Port> --user=<BATCH user> --auth_type=challenge --secret=<PW file>

ParameterDescriptionExample for WindowsExample for Linux
<python interpreter>Open the resp. Python interpreterC:\Python27\python.exe/usr/local/bin/python2.7
<headless path>Directory path headless clients, absolute:
or based on the current directory:
C:\PLANTA\Jobs\Headless\
.\
/planta/jobs/headless/
./
<Server>Name or IP address of the PLANTA Serverlocalhost (if executed on application server)
planta4711.planta.de
10.210.47.11
localhost (if executed on application server)
planta4711.planta.de
10.210.47.11
<Port>Connection port to the serviceStandard is 21000 + System no., e.g. 21001Standard is 21000 + System no., e.g. 21001
<BATCH-User>Name of the PLANTA project batch userBATCHBATCH
<PW file>Path and name of the password file to be generated.\auth_file./auth_file


Example for Windows

C:\Python27\python.exe C:\PLANTA\Jobs\Headless\planta_headless.py --service=planta4711:21001 --user=BATCH --auth_type=challenge --secret=C:\PLANTA\Jobs\Headless\auth_file

Example for Linux

/usr/local/bin/python2.7 ./planta_headless.py --service=localhost:21210 --user=BATCH --auth_type=challenge --secret=./auth_file

  • Password input (password is saved in an encrypted file).
  • Set the rights for the newly created encrypted password file (read/write rights only for the user running the Python program)..

Step 4: Configure Job

Procedure

  • For this purpose, adjust the following Shell/Batch script templates:
    • For the following script, enter the appropriate values in the Adjust parameter: section.
    • Save it as a file (e.g. named Headless.bat under Windows or headless.bsh under Linux) in the headless cient directory. The date timestamp here is dependent on the local format and must possibly be adjusted.
  • Example for Windows
BASH
@ECHO OFF
REM BATCH
REM PLANTA Headless-Client: Durchführung von Batch-Jobs
REM Parameter anpassen:
REM --->
SET PYTHON="<Pfad zu Python (V. 2.6 oder 2.7)>"
SET HEADLESS_DIR="<Pfad zum Headless Client (PLANTA_PY)>"
SET SERVICE=<Serveradresse:Portnummer>
SET USER=BATCH
REM Falls das Arbeitspaket als Startmodul des Batch-Users definiert ist, bleibt dieser Parameter leer,
REM sonst wird hier die Modul-ID des auszuführenden Moduls eingetragen:
SET PLANTA_MODULE=
IF NOT "%PLANTA_MODULE%"=="" SET MODULE_PARAM=--module=%PLANTA_MODULE%
IF "%PLANTA_MODULE%"=="" SET MODULE_PARAM=
REM Falls Logging gewünscht ist, die folgenden Variablen aktivieren,
REM sowie unten den Skript-Aufruf mit Logging aktivieren und den ohne Logging deaktivieren:
REM SET LOG_DIR="<Pfad des Log-Verzeichnisses>"
REM SET LOGFILE="<Präfix für die Log-Datei (z.B. PLANTA_Headless)>"
REM SET DATETIME=%DATE:~-4%-%DATE:~3,2%-%DATE:~0,2%_%TIME:~0,2%-%TIME:~3,2%-%TIME:~6,2%
REM <---
SET AUTH_FILE=".\auth_file"
SET PLANTA_PY=".\planta_headless.py"
SET PLANTA_SH=%PLANTA_PY% --service=%SERVICE% --user=%USER% --auth_type=challenge --secret=%AUTH_FILE% %MODULE_PARAM%
cd %HEADLESS_DIR%
REM Variante ohne Logging:
%PYTHON% %PLANTA_SH% %*
REM Variante mit Logging:
REM forfiles -p %LOG_DIR% -m %LOGFILE%*.log -d -7 -c "cmd /c del @path"
REM %PYTHON% %PLANTA_SH% %* --timeout=-1 -vvv >> %LOG_DIR%\%LOGFILE%_%DATETIME%_%USER%.log
  • Example for Linux:
BASH
#!/bin/bash
# PLANTA Headless-Client: Durchführung von Batch-Jobs
# Parameter anpassen:
# --->
PYTHON="<Pfad zu Python (V. 2.6 oder 2.7)>"
HEADLESS_DIR="<Pfad zum Headless Client (PLANTA_PY)>"
SERVICE="<Serveradresse:Portnr.>"
USER="BATCH"
# Falls das Arbeitspaket als Startmodul des Batch-Users definiert ist, bleibt der folgende Parameter leer,
# sonst wird hier die Modul-ID des auszuführenden Moduls eingetragen:
PLANTA_MODULE=""

if [[ -z $PLANTA_MODULE ]]
then
    MODULE_PARAM=""
else
    MODULE_PARAM="--module=$PLANTA_MODULE"
fi

# Falls Logging gewünscht ist, die folgenden Variablen aktivieren, 
# sowie unten den Skript-Aufruf mit Logging aktivieren und den ohne Logging deaktivieren:
#LOG_DIR="<Pfad des Log-Verzeichnisses"
#LOGFILE="<Präfix für den Log-Datei-Namen (z.B. PLANTA_Headless)>"
#DATETIME=`date +20%y-%m-%d_%H-%M-%S`
# <---
AUTH_FILE="./auth_file"
PLANTA_PY="planta_headless.py"
PLANTA_SH="./$PLANTA_PY --service=$SERVICE --user=$USER --auth_type=challenge --secret=$AUTH_FILE $MODULE_PARAM"
cd $HEADLESS_DIR
# Variante ohne Logging:
$PYTHON $PLANTA_SH $*
# Variante mit Logging:
#find $LOG_DIR -type f -name "$LOGFILE*.log" -mtime +7 -print0 | xargs -0 rm -f
#$PYTHON $PLANTA_SH $* --timeout=-1 -vvv >> $LOG_DIR/$LOGFILE\_$DATETIME\_$USER.log

Step 5: Implementation of the Time-Controlled Call

Note

  • Here, administrator rights are required..

Procedure

  • Setup
    • under Windows: via Task Manager (or Task Planning)
    • under Linux: as a Cron Job
  • In both cases, the job has no information about environment variables, etc. All information it requires must be included in the shell-scripts (e.g. using absolute paths).

Notes

  • The headless client usually starts a PLANTA macro without waiting for its completion.
  • This can be prevented via the timeout=-1 parameter.
  • In this case, the headless client waits for the macro to be completed.
  • See also the logging variant in the shell scripts mentioned above.
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.