tcpdump - How to escape a systemd Specifier to pass to the command in ExecStart -


i've written following systemd service tcpdumpd.service kick off persistent tcpdump recording.

[unit] description=tcpdumpd after=multi-user.target network.target  [service] type=simple execstart=/usr/sbin/tcpdump -pni eth0 -s65535 -g 3600 -w '/var/log/tcpdump/trace_%y-%m-%d_%h:%m:%s.pcap' -z gzip restart=on-abort  [install] wantedby=multi-user.target 

tcpdump allows strftime-placeholders %h hour, %m minute , on allow create time stamped files.

however, systemd has special specifiers can used in it, (%n, %n, %p, %i, %u, %u, %m, %h, %b, %v) of specifiers overlap, %m , %h pass through information systemd , don't allow placeholder passed through tcpdump make time stamp.

does know if there way escape specifiers in systemd can pass %m , %h through tcpdump?

i've tried escape special specifiers %%m, \%m without luck.

but, if need work done, here workaround:

create file tcpdumpd.environment containing definition of tcpdump_format variable.

tcpdump_format=%y-%m-%d_%h:%m:%s 

modify tcpdumpd.service: add environmentfile= option , replace format string ${tcpdump_format}.

[unit] description=tcpdumpd after=multi-user.target network.target  [service] type=simple environmentfile=tcpdumpd.environment execstart=/usr/sbin/tcpdump -pni eth0 -s65535 -g 3600 -w '/var/log/tcpdump/trace_${tcpdump_format}.pcap' -z gzip restart=on-abort  [install] wantedby=multi-user.target 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -