0

My /home directory is having very less memory. But some of my programs which are running in production will create dynamic files in '/home' directory.

The problem is if it reaches to 100% then my program doesn't work. So I have to manually go and delete the files or copy the files.

So rather than doing that I want to redirect the files from '/home' to '/tmp' directory in unix by default.

Please give me some thoughts.

Yaswanth
  • 483
  • 1
  • 9
  • 25
  • 2
    fix your filesystem or your programs instead of looking for work arounds. – 123 Sep 08 '17 at 16:13
  • @123: thanks for your reply. Actually it's not my code, I am using firefox headless browser. So I can't change it. – Yaswanth Sep 11 '17 at 05:40

2 Answers2

1

You have at least two ways to do:

  • if you can config your program to export files to other dir, do this.
  • if you cannot do anything on the program, you can create a cron job, remove/cp those files automatically
Kent
  • 189,393
  • 32
  • 233
  • 301
  • ^1. The output path is very likely configurable. – hek2mgl Sep 08 '17 at 16:00
  • @hek2mgl now I know the meaning of `^`...! – Kent Sep 08 '17 at 16:02
  • You mean *a literal 1 at the start of the line*? :D – hek2mgl Sep 08 '17 at 16:03
  • @Kent: Thanks Kent for your reply. I can't do it through cron job aswell, because here directories are created by firefox in '/tmp'. The biggest problem is it will keep on using that directory which is created, so the size will be keep on increasing. – Yaswanth Sep 11 '17 at 05:36
0

If the program creates files under it's own directory, you can create a symlink:

# Create directory in /tmp
mkdir /tmp/myprog

# Set permissions
chown "${USER}:${USER}" /tmp/myprog
chmod -R o-x /tmp/myprog

# Create symlink at /home/myprog
ln -s /tmp/myprog "${HOME}/myprog"
hek2mgl
  • 152,036
  • 28
  • 249
  • 266
  • I understood the files were written to `$HOME` directly no sub-dir. But if I am wrong, you answer is the most straightforward solution. But it should not be counted as a question then, IMO. :-) – Kent Sep 08 '17 at 16:01
  • Besides that, the question is far off-topic :) – hek2mgl Sep 08 '17 at 16:02
  • I've flagged it. Question and answers can be transferred to superuser.com – hek2mgl Sep 08 '17 at 16:35
  • @hek2mgl : Thanks for your reply, actually as I explained in previous comment to Kent Firefox can't create that symlinks. – Yaswanth Sep 11 '17 at 05:39