As normaluser:
$ ulimit -n 4096
-bash: ulimit: open files: cannot modify limit: Operation not permitted
As root it works as desired - but then it won't affect normaluser.
How to get out of this catch 22? I'll need this to be persistent.
You may want to look at /etc/security/limits.conf
To change file descriptor limit as normal user before running any applicaiton.
I use this small utility fdlimit which will increase file descriptor limit using "setrlimit()" system call before executing any program.
I use it like this
$ sudo ./fdlimit <fdlimit> <program_to_run>
Related
While running make check for mesos-1.9.0 on mac os, I get an error for 'ulimit -u`. This is the error message on Terminal
Detected low process count ulimit (2837 vs 4096). Increase 'ulimit -u' to avoid spurious test failures.
I tried setting the hard and soft limits for ulimit (ulimit -u 4096and ulimit -n 4096) on the Terminal as well as updating my .bash_profile and running source ~/.bash_profile but make check still fails.
Can someone help me fix this ?
TIA.
sudo ulimit -n 65536 200000
Reference: https://wilsonmar.github.io/maximum-limits
I have been trying to get this running for over a week and am at a loss. I am trying to call a script on completion by using the settings.json config like so:
"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/posttorrent.sh",
My script is in the root of the jail and is owned by transmission. I have also checked permissions on the file (which are 755) and have run chmod +x /posttorrent.sh.
I have even simplified the file to just output to a log file like so:
#!/bin/bash
echo "$TR_TORRENT_NAME is completed" >> /posttorrent.log
However, thus far, I still do not have a posttorrent.log file anywhere, no matter what file I download. I am not totally sure if I am on the right track as Transmission is set to log level 3 and yet I do not even see the calls to the script in /var/log/debug.log. I am sure I am missing something easy as others have been able to get this working, I am just out of options now as I think I have read and/or tried everything I could find in relation to this issue. Thanks!
The script is relying on /bin/bash being present inside of the jail.
You can either change the script to use /bin/sh, change /bin/bash
to /usr/bin/env bash, or link /path/to/port/bin/bash to
/usr/local/bin/bash (or wherever bash is located relative to the
jail directory, but if it exists it should be in /usr/local/bin).
ln -s /usr/local/bin/bash /path/to/jail/bin/bash
Also, the root directory (by default) is only writable by root, so
the transmission user would not have permission to create
the log file in the root directory. To properly allow creation of
the log file change the destination directory to one that the
transmission user has permission to write to. For example
/var/db/transmission/posttorrent.log, if using the FreeNAS plugin.
A directory can be created for the transmission user using the
install utility:
install -d -o transmission -g transmission /home/transmission
Alternatively the log file can be created manually using the
install utility, or the owner can be set with chown:
install -o transmission -g transmission -m 644 /dev/null /posttorrent.log
# or on an existing log file
chown transmission /posttorrent.log
chgrp transmission /posttorrent.log
# normally the mode bits will already be 644
chmod 644 /posttorrent.log
Transmission will also rewrite the configuration file when it
exits. So transmission-daemon has to be stopped before
editing the settings file. However, if using the Transmission plugin,
the settings are stored in a SQLite database
(/usr/pbi/transmission-amd64/transmissionUI/transmission.db)
and the settings file will be recreated from the database on
startup. sqlite3 can be used to manually edit the database, or the plugin's settings can be edited on the FreeNAS web UI.
sqlite3 /usr/pbi/transmission-amd64/transmissionUI/transmission.db <<EOF
UPDATE freenas_transmission SET enable=1;
UPDATE freenas_transmission SET script_post_torrent="/posttorrent.sh";
I have a command in my shell script (increment.sh):
TMP_FILE=/tmp/sbg_clickstream.tmp
hive -e "select * from $HIVE_TMP_TABLE;" > $TMP_FILE
I am getting an error on the 2nd line:
/tmp/sbg_clickstream.tmp: Permission denied
Error: Error occured while opening data file
Error: Load Failed, records not inserted.
Load failed (exit code 1)
I tried chmod 750 /tmp/sbg_clickstream.tmp and ran the script again but I am still getting the same error.
I am new to shell scripting and I thought the dir/file is created when TMP_FILE=/tmp/sbg_clickstream.tmp. However after the test above, concluded it does not.
I think the dir/file is created during this line:
hive -e "select * from $HIVE_TMP_TABLE;" > $TMP_FILE
How can I change the permissions while the query is populating and creating the file?
Two questions:
What user is running the script?
Who owns the file /tmp/sbg_clickstream.tmp?
If the user running the script owns the file, then the problem may be with the shell setting itself.
Type set -o from the command line, and check the value of clobber or noclobber. If noclobber is set to on or clobber is set off, then you cannot overwrite files via the redirection. You'll need to set or unset clobber/noclobber.
If your shell has a value for clobber (like the Kornshell), you need to do this:
$ set -o clobber # Turns clobber on
If your shell has a value for noclobber (like BASH), you need to do this:
$ set +o noclobber # Turns noclobber off
Yes, the -o/+o parameters seem backwards.
Hint:
Instead of using the same file name over and over, try this:
TMP_FILE=/tmp/sbg_clickstream.$$.tmp
hive -e "select * from $HIVE_TMP_TABLE;" > $TMP_FILE
The $$ represents the pid, and thus changes all the time. When the system reboots, it should clean out the /tmp directory. Otherwise the PID climbs and shouldn't repeat. This way, each run generates a new temp file, and you don't have to worry about clobbering or not.
Even Better Hint
See if your system has a mktemp command. This will generate a unique temporary file name:
TMP_FILE=$(mktemp -t sbg_clickstream.XXXXX)
echo "The tempfile is '$TMP_FILE'
hive -e "select * from $HIVE_TMP_TABLE;" > $TMP_FILE
This may echo something like this:
The tempfile is /tmp/sbg_clickstream.Ds23d
mktemp is guaranteed to create a valid and unique temporary file name.
chmod/chown is your friend but you need to ensure that the user/group running the shell script has permission to write to the /tmp directory.
What is the output of the following:
ls -ld /tmp
whoami
groups
I'm installing a lighttpd server on a remote machine using a bash script. After installation, I need to configure the port for the server. The system says I don't have permission to modify the file /etc/lighttpd/lighttpd.conf even though I do
sudo echo "server.bind=2000" >> /etc/lighttpd/lighttpd.conf
How shall I modify this?
What you're doing is running echo as root, then trying to append its output to the config file as the normal user.
What you want is sudo sh -c 'echo "server.bind=2000" >> /etc/lighttpd/lighttpd.conf'
Try to change the file permission using chmod
$ sudo chmod a+x /etc/lighttpd/lighttpd.conf
If you don't have the right to change the file /etc/lighttpd/lighttpd.conf check the man page of lighthttpd. If you can start it with a different config file, then create a config file somewhere and start lighthttpd with it.
The problem is that the bit on the right of >> is not run under sudo. Either use sudo -i to bring up a root shell a superuser and run the command, or just use an editor as mentioned before.
It looks that OS X (10.6) does not generates codedumps by default.
Using the ulimit -c unlimited is not a good solution because ulimit does set the limit in an environment variable. This will work only for console applications executed from the shell that executed ulimit. If you have a gui application this will not work.
You can enable core dumps and then launch your GUI app from the command line using open.
$ ulimit -c unlimited
$ open /Applications/Address\ Book.app
I just looked at TN2124 and it suggests a similar approach, only without using open and just launching the app directly, e.g.
$ ulimit -c unlimited
$ /Applications/TextEdit.app/Contents/MacOS/TextEdit