Redirection to other directories

816 views Asked by At

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.

2

There are 2 answers

4
Kent On

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
4
hek2mgl On

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"