Tag Info

Hot answers tagged

128

Emptying the buffers cache If you ever want to empty it you can use this chain of commands. # free && sync && echo 3 > /proc/sys/vm/drop_caches && free total used free shared buffers cached Mem: 1018916 980832 38084 0 46924 355764 -/+ buffers/cache: 578144 ...


115

bash does cache the full path to a command. You can verify that the command you are trying to execute is hashed with the type command: $ type svnsync svnsync is hashed (/usr/local/bin/svnsync) To clear the entire cache: $ hash -r Or just one entry: $ hash -d svnsync For additional information, consult help hash and man bash.


49

Not grep as such, but the filesystem itself often caches recently read data, causing later runs to go faster since grep is effectively searching in memory instead of disk.


31

From http://www.lindevdoc.org/wiki//var/cache Sorry for the (very) late answer, but I believe it's important to include this bit for future reference. Highlighted the bit which does answer this question. The /var/cache directory contains cached files, i.e. files that were generated and can be re-generated any time, but they are worth storing to save ...


23

There is no need to do this, the kernel manages RAM efficiently by using it for caches and buffers if it is not needed by processes. If processes request more RAM the kernel will deallocate caches and buffers if necessary to satisfy the request. This ServerFault answer explains how to interpret the memory usage reported by free.


18

Use this Bash script to get a list with all temporarily saved Flash videos: #!/usr/bin/env bash for flashpid in $(pgrep -f flashplayer.so); do cd "/proc/$flashpid/fd" for video in $(file * | grep '/tmp/Flash' | sed 's/\(^[0-9]*\).*/\1/g'); do echo "/proc/$flashpid/fd/$video" done done Mark the script as executable and run, for example ...


17

To clear just one entry you need a different flag: hash -d svnsync The -r flag doesn't take a parameter and will always delete the entire cache. (At least in bash 3.2.39 on Debian Lenny)


16

Linux and *NIX systems make use of various caches which sit between the filesystems (abstracted through VFS) and the user level processes. So it's not grep and it's not the filesystem doing the caching - it's the operating system. The cache which is responsible for your grep performance is the VFS Buffer Cache. Other caches are for inodes and directories ...


15

Bcache could be exactly what you're looking for: Bcache is a Linux kernel block layer cache. It allows one or more fast disk drives such as flash-based solid state drives (SSDs) to act as a cache for one or more slower hard disk drives. I'm eagerly awaiting its inclusion into Linux mainline, but unfortunately it's still not quite there. Some nice and ...


15

According to the varnish documentation, it's varnishd -V


14

No, it doesn't. The issue isn't with the type of disk (spinning/non-spinning), it's with committing disk buffers from RAM to disk. If the power goes out suddenly, some of these buffers may never get committed to disk, and having barriers enabled improves your chances of recovering the filesystem. There's also an additional issue with the disk's on-board ...


14

It is safe to clear ~/.cache/, new user accounts start with an empty directory anyway. You might want to log out after doing this though since programs might still use this directory. These programs can be found with this command: find ~/.cache -print0 | xargs -0 lsof -n In my case I would most likely be fine with just closing Firefox before removal.


12

No. For one, I believe that /var/cache/bind/ is the default directory where bind9 expects its zone files to be stored (at least on Debian; I don't know offhand if other distros follow suit) For another, according to this documentation, pacman (the package manager used by Arch linux) stores its package cache under /var/cache/pacman/pkg/ and it most likely ...


11

What you are seeing when you rerun a du command is the effect of disk buffering. Once you read a block its disk buffer is kept in the buffer cache until that block is needed. For du you need to read the directory and the inode for each file in the directory. The du results are not cached in this case, but can be derived with far less disk IO. While it ...


11

The first line of the free output lists: total Your total, physical (assuming no virtualization) memory used How much of that is currently used (by anything) free How much of that is completely free (not used at all) shared (never anything there, ignore that column) buffers Memory used by kernel buffers cached Memory used for cache The last two items, ...


11

Well, in short: a warm cache is useful whereas a cold cache is not. In fact, a cold cache can be dangerous to use. You see, the whole point of a cache is to keep oft-accessed data accessible. For instance a DNS cache will store locally the results of the name-resolutions that you've requested recently, and, when those same resolutions are requested again ...


10

The reason why you are missing the cache hits is that dig queries the DNS directly. You can try and see whether the cache works with the getent command: getent hosts host.example.com Running a separate caching DNS is a good idea, but you should consider running it on the network level if possible. If each host cache the data separately they will still run ...


10

Potential Method #1 - F_DROP_CACHES I found a method from 2012 that discusses a proposed patch to the Linux kernel in this mail thread titled: Re: [RFC Patch] fs: implement per-file drop caches. excerpt Cong> This is a draft patch of implementing per-file drop caches. Interesting. So can I do this from outside a process? I'm a SysAdmin, so my ...


9

I don't think you can, easily, tell it "temporarily stop caching". But what you can do is tell the system to drop the cache before each run: As root: sync; echo 3 > /proc/sys/vm/drop_caches (This is documented in the kernel docs at Documentation/sysctl/vm.txt, which is handy if like some of us you can't always remember offhand what the values 1, 2, or ...


9

After some more research, I have found that the term SwapCached in /proc/meminfo is misleading. In fact, it relates to the number of bytes that are simultaneous in memory and swap, such that if these pages are not dirty, they do not need to be swapped out.


9

Zram creates a block device backed by compressed ram. You can use that block device for swap. Normally memory pressure first results in the cache being discarded, and only after most of the cache has been freed up and memory is still tight does the system start swapping. CleanCache allows pages from the page cache to be migrated to a back end, such as xen ...


9

Use lscpu. It's in Debian package “util-linux”.


8

You don't need to do so. There are two possiblities, if there is something in the cache: it is needed again it is not needed again In the first case, it is better if it remains in RAM as long as possible, which means: another process needs the RAM. Then it is discarded automatically without your intervention. In the second case, it doesn't disturb. ...


7

As an addition to the above answer, also see https://lwn.net/Articles/454795 for a detailed explanation of the technology. From what I understand, zram will be superseded by frontswap, which is not yet in the mainline kernel but which has the advantage that no fixed swap size has to be configured. This will make it easy to enable both cleancache and ...


7

Check these items, and see if any work for you: On the client, if you're not already using the cto option in the options column of the /etc/fstab line for your NFS filesystem, add it. cto tells the nfs client to open files via close-to-open, which makes them refresh the file whenever they open it. On the server, make sure your filesystem is exported with ...


7

you can remount with sync option and then remount it back with async: mount -o remount,sync /mountpoint mount -o remount,async /mountpoint Using remount option will not mess with processes using remounted filesystem.


7

Depending on what you want to do you can use 1,2 or 3 from https://www.kernel.org/doc/Documentation/sysctl/vm.txt drop_caches Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free. To free pagecache: echo 1 > /proc/sys/vm/drop_caches To free dentries and inodes: echo 2 > ...


7

bchache might be what you are looking for. It can act as write through or write back cache. ZFS and Btrfs also have features to put more often used blocks on flash storage.


7

To control how Linux caches things refer to this https://www.kernel.org/doc/Documentation/sysctl/vm.txt In particular look at vfs_cache_pressure, you probably want a really low value or maybe even zero (1 sounds a bit safer to me though): vfs_cache_pressure ------------------ Controls the tendency of the kernel to reclaim the memory which is used for ...


7

Yes it is safe, but before you just throw it all away check what is in there. The files under .cache are used to speed up your programs e.g. by not causing downloads when not necessary. Some content there might immediately have to be downloaded or recreated again. du -sm ~/.cache/* will give you a list and you can selectively remove any of those ...



Only top voted, non community-wiki answers of a minimum length are eligible