Can i delete this file ?


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Can i delete this file ?
# 1  
Old 04-07-2019
Can i delete this file ?

Hi,

On my linux system i find the below two files which occupy good space.

Code:
# du -sh /root/myswapfile /swap2
1.1G    /root/myswapfile
1001M   /swap2

# ls -ltr /root/myswapfile /swap2
-rw-------. 1 root root 1073741824 Jan 27  2017 /root/myswapfile
-rw-------. 1 root root 1048576000 Jan 31  2017 /swap2

Current output of top command:

Quote:
top - 17:53:54 up 140 days, 7:47, 1 user, load average: 0.46, 0.61, 0.46
Tasks: 126 total, 1 running, 125 sleeping, 0 stopped, 0 zombie
%Cpu(s): 4.1 us, 1.7 sy, 0.0 ni, 91.5 id, 2.4 wa, 0.0 hi, 0.3 si, 0.0 st
KiB Mem : 1883724 total, 81828 free, 808324 used, 993572 buff/cache
KiB Swap: 2072568 total, 2972 free, 2069596 used. 799180 avail Mem
Code:
# free
              total        used        free      shared  buff/cache   available
Mem:        1883724      962668       79056       11064      842000      645476
Swap:       2072568     2008324       64244

Code:
# uname -a
Linux mymac1 3.10.0-514.10.2.el7.x86_64 #1 SMP Fri Mar 3 00:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Considering my current memory usage is it safe to remove (rm) any of the two files ?
# 2  
Old 04-07-2019
Hello mohtashims,

I am little bit confuse here, not sure why you are looking for deleting the files? When we hit top command it will show us(you could sort it by memory or cpu consumed order) which process is responsible for high cpu or memory before simply pointing few files(since they are of huge size) to delete them.

Please paste output of top command and make sure they have high memory or cpu related processes details in it, then we could try to move further at this point it is NOT clear.

Thanks,
R. Singh
# 3  
Old 04-07-2019
Those look like something that might have been created by the mkfile utility for use as NFS mounted swap areas. (Although I would usually expect to see them with a set-uid bit set for the owner in this case.)

In any case, I would be very wary of removing two gigabytes of someone's data without knowing why it is there and what it is being used for first.
This User Gave Thanks to Don Cragun For This Post:
# 4  
Old 04-07-2019
@Don, why NFS??
Check if they are used as (local) swap files, with
Code:
cat /proc/swaps

or
Code:
swapon -s

and (to be mounted at boot)
Code:
cat /etc/fstab

This User Gave Thanks to MadeInGermany For This Post:
# 5  
Old 04-07-2019
Hi MadeInGermany,
I was just quoting from the MacOS mkfile(8) man page:
Code:
NAME
       mkfile - create a file

SYNOPSIS
       mkfile [ -nv ] size[b|k|m|g] filename ...

DESCRIPTION
       mkfile  creates  one  or  more  files that are suitable for use as NFS-
       mounted swap areas.  The sticky bit is set, and the file is padded with
       zeroes  by  default.   Non-root  users  must  set  the sticky bit using
       chmod(1).  The default size unit is bytes, but the  following  suffixes
       may  be  used  to  multiply  by  the given factor: b (512), k (1024), m
       (1048576), and g (1073741824).
... ... ...

I didn't remember it being for NFS only either, but I haven't personally used mkfile since I left Sun over a decade ago.
# 6  
Old 04-08-2019
Quote:
Originally Posted by MadeInGermany
@Don, why NFS??
Check if they are used as (local) swap files, with
Code:
cat /proc/swaps

or
Code:
swapon -s

and (to be mounted at boot)
Code:
cat /etc/fstab

Can you tell me if it is used and required (should not be deleted) inlight with the below output:

Code:
cat /proc/swaps
Filename                                Type            Size    Used    Priority
/root/myswapfile                        file            1048572 1041852 -1
/swap2                                  file            1023996 538916  -2

# swapon -s
Filename                                Type            Size    Used    Priority
/root/myswapfile                        file    1048572 1041852 -1
/swap2                                  file    1023996 538916  -2

# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Thu Dec 15 22:52:03 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=4402acfe-bd46-475b-b78c-cc0aef5b78f7 /                       ext4    defaults        1 1
/root/myswapfile        swap                    swap    defaults        0 0
/swap2                  swap                    swap    defaults        0 0

# 7  
Old 04-08-2019
In my opinion, the you should change your config settings to not to mount the swap space when the system boots, then do an orderly shutdown and reboot.

Then you will be OK.

Sorry, I did not look at your system and think about how to configure it to not mount and / or use swap when it boots, but if you configure your system to not use swap when it boots, then you reboot in an orderly way, you should be OK.

I don't recommend just "deleting" that space without an orderly plan / method to first boot without the swap, and then after you are comfortable all is working as you expect, you can reclaim the disk space as you wish.
This User Gave Thanks to Neo For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Delete files whose file names are listed in a .txt file

hi, I need a help. I used this command to list all the log files which are for more than 10 days to a text file. find /usr/script_test -type f -mtime +10>>/usr/ftprm.txt I want all these files listed in the ftprm.txt to be ftp in another machine and then rm the files. Anyone can help me... (8 Replies)
Discussion started by: kamaldev
8 Replies

2. Red Hat

Need Script to ZIP/SAVE & then DELETE Log file & DELETE ZIPS older than 12 months

ENVIROMENT Linux: Fedora Core release 1 (Yarrow) iPlanet: iPlanet-WebServer-Enterprise/6.0SP1 Log Path: /usr/iplanet/servers/https-company/logs I have iPlanet log rotation enabled rotating files on a daily basis. The rotated logs are NOT compressed & are taking up too much space. I... (7 Replies)
Discussion started by: zachs
7 Replies

3. Shell Programming and Scripting

Compare two string in two separate file and delete some line of file

Hi all i want to write program with shell script that able compare two file content and if one of lines of file have # at the first of string or nothing find same string in one of two file . remove the line in second file that have not the string in first file. for example: file... (2 Replies)
Discussion started by: saleh67
2 Replies

4. UNIX for Dummies Questions & Answers

To delete the oldest files in a file when file count in the folder exceeds 7

Hi All, I need to delete the oldest file in folder when the file count in the folder exceed 6 ( i have a process that puts the source files into this folder ) E.x : Folder : /data/opt/backup 01/01/2012 a.txt 01/02/2012 b.txt ... (1 Reply)
Discussion started by: akshay01987
1 Replies

5. Shell Programming and Scripting

Need unix commands to delete records from one file if the same record present in another file...

Need unix commands to delete records from one file if the same record present in another file... just like join ... if the record present in both files.. delete from first file or delete the particular record and write the unmatched records to new file.. tried with grep and while... (6 Replies)
Discussion started by: msathees
6 Replies

6. Shell Programming and Scripting

Delete a pattern present in file 2 from file 1 if found in file 1.

I have two files File1 ==== 1|2000-00-00|2010-02-02|| 2| 00:00:00|2012-02-24|| 3|2000-00-00|2011-02-02|| File2 ==== 2000-00-00 00:00:00 I want the delete the patterns which are found in file 2 from file 1, Expected output: File1 ==== (5 Replies)
Discussion started by: machomaddy
5 Replies

7. Homework & Coursework Questions

how to delete core file (file created due to apps crashed)

1. The problem statement, all variables and given/known data: When looking for corefiles, include any file with core in its name. (Some UNIX/Linux systems add the PID of the process that created the core to reduce the chances of overwriting an already existing core file that might be needed. The... (6 Replies)
Discussion started by: s3270226
6 Replies

8. Solaris

Before I delete any file in Unix, How can I check no open file handle is pointing to that file?

I know how to check if any file has a unix process using a file by looking at 'lsof <fullpath/filename>' command. I think using lsof is very expensive. Also to make it accurate we need to inlcude fullpath of the file. Is there another command that can tell if a file has a truely active... (12 Replies)
Discussion started by: kchinnam
12 Replies

9. Shell Programming and Scripting

How to delete a string pattern in a file and write back to the same file

I have a control file which looks like this LOAD DATA INFILE '/array/data/data_Finished_T5_col_change/home/oracle/emp.dat' PRESERVE BLANKS INTO TABLE SCOTT.EMP FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS (................. ..................) How can i edit the... (1 Reply)
Discussion started by: mwrg
1 Replies

10. Shell Programming and Scripting

Delete block of text in one file based on list in another file

Hi all I currently use the following in shell. #!/bin/sh while read LINE do perl -i -ne "$/ = ''; print if !m'Using archive: ${LINE}'ms;" "datafile" done < "listfile" NOTE the single quote delimiters in the expression. It's highly likely the 'LINE' may very well have characters in it... (3 Replies)
Discussion started by: Festus Hagen
3 Replies
Login or Register to Ask a Question