Tag Info

Hot answers tagged

17

The reason is that the operating system needs memory to manage each open file, and memory is a limited resource - especially on embedded systems. As root user you can change the maximum of the open files count per process (via ulimit -n) and per system (e.g. echo 800000 > /proc/sys/fs/file-max).


16

It's not that difficult to decipher in fact. This piece of code just defines a function named : which calls two instances of itself in a pipeline: :|:&. After the definition an instance of this function is started. This leads to a fast increasing number of subshell processes. Unprotected systems (systems without a process number limit per user) will be ...


15

ulimit is made for this. You can setup defaults for ulimit on a per user or a per group basis in /etc/security/limits.conf ulimit -v KBYTES sets max virtual memory size. I don't think you can give a max amount of swap. It's just a limit on the amount of virtual memory the user can use. So you limits.conf would have the line (to a maximum of 4G of ...


13

Have a look at trickle a userspace bandwidth shaper. Just start your shell with trickle and specify the speed, e.g.: trickle -d 100 zsh which tries to limit the download speed to 100KB/s for all programs launched inside this shell. As trickle uses LD_PRELOAD this won't work with static linked programs but this isn't a problem for most programs.


11

ulimit -v, it's a shell builtin, but it should do what you want. I use that in init scripts sometimes: ulimit -v 128k command ulimit -v unlimited It seems however, that you want ways of manipulating the maximum allocatable memory while the program is running, is that correct? Probably something like renice for manipulating the Priority. There is, ...


9

If your program doesn't need to write any OTHER files that would be larger than this limit, you can inform the kernel of this limit using ulimit. Before you run your command, run this to setup a 200MB file size limit for all process run in your current shell session: ulimit -f $((200*1024)) This will protect your system but it might be jaring for the ...


9

When logging in using SSH, you use a pseudo-terminal (a pty) allocated to the SSH daemon, not a real one (a tty). Pseudo-terminals are created and destroyed as needed. You can find the number of ptys allowed to be allocated at one time at /proc/sys/kernel/pty/max, and this value can be modified using the kernel.pty.max sysctl variable. Assuming that no other ...


8

You can probably achieve something like that by using cgroups with the Memory resource controller. I guess you'd put all your resource-consuming tasks in a limited (CPU & RAM) cgroup, and leave sshd "outside" so that it isn't restricted. (Adding more swap, even in the form of a swap file, might be a good option though.)


6

Under Linux, execute the sched_setaffinity system call. The affinity of a process is the set of processors on which it can run. There's a standard shell wrapper: taskset. For example, to pin a process to CPU #0 (you need to choose a specific CPU): taskset -c 0 mycommand --option # start a command with the given affinity taskset -c 0 -p 1234 # ...


6

If your application (ie. run_program) does not support limiting the size of the log file, then you can check the file size periodically in a loop with an external application or script. You can also use logrotate(8) to rotate your logs, it has size parameter which you can use for your purpose: With this, the log file is rotated when the specified size ...


6

From within a program, call setrlimit(RLIMIT_CPU, ...). From the shell, call ulimit -t 42 (this is not standard but supported by most shells (including bash and ksh) on most unix variants). This causes the current process to be killed once it has used up N seconds of CPU time. The limitation is inherited by child processes. A common shell idiom is (ulimit -t ...


5

Most systems use PAM, and have the pam_limits module set limits based on /etc/security/limits.conf. The per-user limit for open files is called nofile. You can set it for every user or for a particular user or group, and you can set a limit that the user can override (soft limit) and another that only root can override (hard limit). The documentation and the ...


5

You can try the cpulimit tool which does limit the CPU percentage. It is not a standard tool, so you will have to install it. Here is a quick excerpt of the README: "Cpulimit is a tool which attempts to limit the CPU usage of a process (expressed in percentage, not in CPU time). [...] The control of the used cpu amount is done sending SIGSTOP and ...


5

You can use pv to throttle the bandwidth of a pipe. Since your use case is strongly IO-bound, the added CPU overhead of going through a pipe shouldn't be noticeable, and you don't need to do any CPU throttling. tar cf - mydata | pv -L 1m >/media/MYDISK/backup.tar


5

I don't have HP-UX available to me, and I've never been a big HP-UX fan. It appears that on Linux, a per-process or maybe per-user limit on how many child processes exists. You can see it with the limit Zsh built-in (seems to be analogous to ulimit -u in bash): 1002 % limit cputime unlimited filesize unlimited datasize unlimited ...


5

A process can change its limits via the setrlimit(2) system call. When you run ulimit -n you should see a number. That's the current limit on number of open file descriptors (which includes files, sockets, pipes, etc) for the process. The ulimit command executed the getrlimit(2) system call to find out what the current value is. Here's the key point: a ...


4

If you read the manpage for semget, in the Notes section you'll notice: System wide maximum number of semaphore sets: policy dependent (on Linux, this limit can be read and modified via the fourth field of /proc/sys/kernel/sem). On my system, cat /proc/sys/kernel/sem reports: 250 32000 32 128 So do that on your system, and then echo it back after ...


4

I'm not very sure about this, but you could also use cgroups to limit the memory usage. The advantage of cgroups is that you can control processes that are already running. By the way systemd will use cgroups to control the system services. Unfortunately I've experimented a bit and they don't seem to work very well on my Fedora 13 system.


4

You may create a new filesystem image, mount it using loop device and put the log file on that filesystem: dd if=/dev/zero of=./200mb.img bs=1024 count=200000 # create new empty 200MB file mkfs.ext2 200mb.img # or ext3, or whatever fits your needs mkdir logs sudo mount -t ext2 -o loop 200mb.img logs # only root can do '-o loop' by default run_program ...


4

I don't know what HP-UX's limits are. I can tell you however that the logical implementation is to have a process table with a maximum size. The total number of process table entries is theoretically limited by the range of process IDs, but most implementations have a size limit for the table which yields a much smaller maximum. Most unix variants have a ...


4

That is certainly not trivial task that can't be done in userspace. Fortunately, it is possible to do on Linux, using cgroup mechanizm and its blkio controller. Setting up cgroup is somehow distribution specific as it may already be mounted or even used somewhere. Here's general idea, however (assuming you have proper kernel configuration): mount tmpfs ...


4

Most of the values¹ in limits.conf are limits that can be set with the ulimit shell command or the setrlimit system call. They are properties of a process. The limits apply independently for each process. In particular, each process can have up to nofile open files. There is no limit to the number of open files cumulated by the processes of a user. The ...


4

Someone suggested in your hear cgroups. Well, try to seek that direction as it can provide you with: applied to a group of task you choose (thus not system wide but neither per process) the limits are set for the group the limits are static they can enforce hard limit on memory and/or memory+swap Something like that could bring you closer to your goals: ...


3

Try the mod_qos Apache module. The current version has the following control mechanisms. The maximum number of concurrent requests to a location/resource (URL) or virtual host. Limitation of the bandwidth such as the maximum allowed number of requests per second to an URL or the maximum/minimum of downloaded kbytes per second. Limits the number of request ...


3

I think it's largely for historical reasons. A Unix file descriptor is a small int value, returned by functions like open and creat, and passed to read, write, close, and so forth. At least in early versions of Unix, a file descriptor was simply an index into a fixed-size per-process array of structures, where each structure contains information about an ...


3

There's also the ulimit mechanism. There's a system call (in Linux, it's a C library function) ulimit(3) and a Bash builtin ulimit. Type ulimit -a to see all the things you can limit to. To see the current virtual memory limit say ulimit -v. You can set it by saying ulimit -v INTEGER-KILOBYTES. Running ulimit changes things for your current shell, and you ...


3

I believe the correct format is: @users - priority 10 username - priority 19 This is an example of the settings I am using in production (obviously with real users/groups). The nice setting is to determine the maximum nice value someone can set their process to, not their default priority.


3

Shared memory is not always a protected resource. As such many users can allocate shared memory. It is also not automatically returned to the memory pool when the process which allocated it dies. This can result in shared memory allocations which have been allocated but not used. This results in a memory leak that may not be obvious. By keeping shared ...


3

If your version of ls has a way not to sort files, such as -U for GNU ls, use it. With no option, ls will first read all the files, then sort the names, then start printing. Another possibility is to run find, which prints names as it finds them. find . -type d \! -name . -print -prune -o -print | head


3

Yes, it's the length in bytes, including the environment. Very roughly: $ { seq 1 314290; env; } | wc -c 2091391 linux sysconf The maximum length of the arguments to the exec(3) family of functions. Must not be less than _POSIX_ARG_MAX (4096). POSIX 2004 limits.h Maximum length of argument to the exec functions including ...



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