Suppose we want to compress (using bzip2
) a number of log files.
Distrubute jobs to several threads on local machine. The commands (for each input file) are executed in current working directory.
ls *.log| parallel -j+0 bzip2 -9 '{}'
Services declared as oneshot
are expected to take some action and exit immediatelly (thus, they are not really services,
no running processes remain). A common pattern for these type of service is to be defined by a setup and a teardown action.
Let's create a example foo
service that when started creates a file, and when stopped it deletes it.
Create executable file /opt/foo/setup-foo.sh
:
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId></groupId> | |
<artifactId></artifactId> | |
<version>1.0.0-SNAPSHOT</version> |
log4j.rootLogger=INFO, CONSOLE | |
# CONSOLE is set to be a ConsoleAppender using a PatternLayout | |
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender | |
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout | |
log4j.appender.CONSOLE.layout.ConversionPattern=[%-5p] %m%n | |
# a more detailed PatternLayout: %d [%t] %-5p %c - %m%n | |
# adjust specific logger levels as per the need to control the verbosity of logs |