LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-16-2018, 08:51 AM   #1
linuxforest
LQ Newbie
 
Registered: Sep 2018
Posts: 3

Rep: Reputation: Disabled
systemd: WorkingDirectory=/tmp affects other processes


Hello,

I am using the following service file for systemd on EL7 OS :

# cat /lib/systemd/system/mytest.service

[Service]
Type=simple
Restart=always
StandardOutput=tty
StandardError=tty
WorkingDirectory=/tmp
ExecStart=/bin/bash -c " <my java server command>'

[Install]
WantedBy=multi-user.target

I am experiencing some unexpected/weird behavior where when this service is enabled and started (only the first time after reboot), /tmp is cleaned up, other processes which have files in /tmp start failing. If disable the service and reboot, the original files in /tmp are back!

Here are the steps I followed :

1. Reboot
2. Put some dummy files in /tmp
3. Create the above service file in /lib/systemd/system/mytest.service
4. systemctl daemon-reload
5. systemctl enable mytest
6. systemctl start mytest

After the last step, the dummy files from /tmp are gone and /tmp is empty for ALL processes.
Processes which have files in /tmp start failing.
After running 'systemctl disable myservice' and rebooting the VM, the dummy files in /tmp are back!

I tried understanding what's going on from the docs. The closest I got was private tmp space settings. if the current service is getting a private tmp space, I am not sure why the other processes are seeing the new empty private tmp space.
My workaround/solution would be to not use WorkingDirectory=/tmp because I can live without that and it seems to fix the problem,
but I would like to understand what happened here and what's wrong with the above service file.

Any help appreciated!
Thanks a lot!!

Last edited by linuxforest; 09-17-2018 at 01:53 PM.
 
Old 09-16-2018, 04:08 PM   #2
JeremyBoden
Senior Member
 
Registered: Nov 2011
Distribution: Debian
Posts: 1,342

Rep: Reputation: 272Reputation: 272Reputation: 272
One of the processes in systemd is to clear /tmp and is presumably dependent on whether various systemd processes have finished starting.

I don't like systemd - why would it use a directory like /tmp when it could use its own tmp directory?
It makes better sense to clear /tmp as soon as you've mounted your /etc/fstab directories...

Last edited by JeremyBoden; 09-16-2018 at 04:13 PM.
 
Old 09-17-2018, 01:27 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 9,413
Blog Entries: 7

Rep: Reputation: 2334Reputation: 2334Reputation: 2334Reputation: 2334Reputation: 2334Reputation: 2334Reputation: 2334Reputation: 2334Reputation: 2334Reputation: 2334Reputation: 2334
the behavior isn't weird at all.
this is weird:
WorkingDirectory=/tmp
and should be changed to something that isn't used by other processes.
 
Old 09-17-2018, 04:33 PM   #5
linuxforest
LQ Newbie
 
Registered: Sep 2018
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks a lot guys. That is very helpful information!
 
Old 09-19-2018, 11:51 PM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 9,413
Blog Entries: 7

Rep: Reputation: 2334Reputation: 2334Reputation: 2334Reputation: 2334Reputation: 2334Reputation: 2334Reputation: 2334Reputation: 2334Reputation: 2334Reputation: 2334Reputation: 2334
this forum is a 2-way street.
please share your solution.
others will benefit.
 
Old 09-20-2018, 08:09 AM   #7
linuxforest
LQ Newbie
 
Registered: Sep 2018
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
this forum is a 2-way street.
please share your solution.
others will benefit.
Oops sorry about that. I should have posted that I am using the same solution that I had in my first post and that was confirmed/recommended here.
I removed WorkingDirectory=/tmp from the service file because I don't really need the working directory.

Thanks of your help!
 
Old 09-20-2018, 09:10 PM   #8
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,380

Rep: Reputation: 979Reputation: 979Reputation: 979Reputation: 979Reputation: 979Reputation: 979Reputation: 979Reputation: 979
Just a footnote: https://access.redhat.com/blogs/766093/posts/1976243
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] udev-initiated long-running processes under systemd without a service. Possible? catkin Programming 3 08-31-2015 04:59 AM
LXer: How to manage processes with cgroup on Systemd LXer Syndicated Linux News 0 04-12-2015 04:51 PM
Systemd - tmp file pedrodurek Linux - Software 1 11-15-2014 07:40 PM
problem in my /tmp folder affects Firefox's loading newbiesforever Linux - General 5 10-25-2009 05:07 PM
Can't login, says tmp directory full but tmp file is empty! Could be linked to MySQL? bethanlowder Fedora 7 09-25-2009 07:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration