Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
0
votes
1
answers
2926
views
Use aliases as custom commands in terminator
I am using a terminator layout to start multiple terminals, and would like to call an alias at each terminal start which is defined in my `.bash_aliases` (called by both `.bashrc` and `.profile`). Terminator unfortunately doesn't know about those aliases when starting the terminals. How can I fix th...
I am using a terminator layout to start multiple terminals, and would like to call an alias at each terminal start which is defined in my
.bash_aliases
(called by both .bashrc
and .profile
). Terminator unfortunately doesn't know about those aliases when starting the terminals. How can I fix that?
I start terminator with this command:
terminator -l my_layout -f
EDIT:
As a temporary solution, I ssh -A -YC
into myself and then run the alias. All this as a custom command.
Mehdi
(422 rep)
Nov 18, 2015, 01:48 PM
• Last activity: Jul 31, 2025, 05:05 PM
136
votes
14
answers
276203
views
Generate random numbers in specific range
After googling a bit I couldn't find a simple way to use a shell command to generate a random decimal integer number included in a specific range, that is between a minimum and a maximum. I read about `/dev/random`, `/dev/urandom` and `$RANDOM`, but none of these can do what I need. Is there another...
After googling a bit I couldn't find a simple way to use a shell command to generate a random decimal integer number included in a specific range, that is between a minimum and a maximum.
I read about
/dev/random
, /dev/urandom
and $RANDOM
, but none of these can do what I need.
Is there another useful command, or a way to use the previous data?
BowPark
(5155 rep)
Jul 4, 2014, 12:18 PM
• Last activity: Jul 29, 2025, 08:39 AM
7
votes
2
answers
77351
views
When I run "sudo su" I get --bash: command not found for everything
I'm not good with command lines or servers. But I needed to configure for work a AMI of EC2 AWS with LINUX So I've installed a lot of stuff, moved a lot of stuff around and then I realized that sudo was not behaving normally. Before, when I typed `sudo`, I would become a root user right away. Now wh...
I'm not good with command lines or servers.
But I needed to configure for work a AMI of EC2 AWS with LINUX
So I've installed a lot of stuff, moved a lot of stuff around and then I realized that sudo was not behaving normally. Before, when I typed
sudo
, I would become a root user right away. Now when I type sudo
, I get the command instructions (as if I had typed --help)
[ec2-user@ip-172-31-33-121 ~]$ sudo
usage: sudo [-D level] -h | -K | -k | -V
usage: sudo -v [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-u username|#uid]
usage: sudo -l[l] [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-U username] [-u user name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-r role] [-t type] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u user name|#uid] [-g groupname|#gid [VAR=value] [-i|-s] []
usage: sudo -e [-AknS] [-r role] [-t type] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u user name|#uid] file .
To become a root user *now* on my server I have to type sudo su
. But once I do that all the commands stop working!
[root@ip-172-31-33-121 ec2-user]# yum
bash: yum: command not found
I've read somewhere it could be a problem with my PATH, and I remember I did changed something on the PATH variable while doing some installations but I can't remember exactly what and why, I think it was when I was trying to install node.js or npm, anyway I'm not sure how to restore my PATH and if that is really the problem
*I tried to restore my path, but I don't know how it was before, so or I restored it and it isn't the problem or I didn't really restored it.
Output of echo $PATH
:
[root@ip-172-31-33-121 ~]# echo $PATH
/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/local/bin:/opt/aws/bin:/root/bin
But I'm really new with this server config stuff, I have no idea if this is right... or wrong
When I run sudo -i
:
[ec2-user@ip-172-31-33-121 ~]$ sudo -i
-bash: id: command not found -bash: tty: command not found
[root@ip-172-31-33-121 ~]# uname -a
Linux ip-172-31-33-121 3.14.44-32.39.amzn1.x86_64 #1 SMP Thu Jun 11 20:33:38 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
## UPDATE ##
As mentioned in the answers it was verified that /usr/bin was missing from my $PATH, so I've added it to my $PATH, and now when I get root by sudo su
the commands are recognized, but if I get root by sudo -i they are still not recognizable, I still get the same error:
[ec2-user@ip-172-31-33-121 ~]$ sudo -i -bash: id: command not found -bash: tty: command not found –
[root@ip-172-31-33-121 ~]# yum -bash: yum: command not found
## UPDATE 2 ##
We've identified that there is something overwriting my $PATH when i restart my shell
when I reopen my shell my $PATH variable is overwritten to this:
[root@ip-172-31-33-121 ec2-user]# echo $PATH
/sbin:/bin:/usr/sbin:/usr/local/bin:/opt/aws/bin
So I lose the /usr/bin again.
We've thought changing the .bashrc would fix it, but it didn't
this is my .bashrc now:
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
PATH=$PATH:/usr/bin; export PATH
# User specific aliases and functions
The result of env command:
[root@ip-172-31-33-121 ec2-user]# env
LESS_TERMCAP_mb=
HOSTNAME=ip-172-31-33-121
LESS_TERMCAP_md=
LESS_TERMCAP_me=
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
EC2_AMITOOL_HOME=/opt/aws/amitools/ec2
PYTHON_INSTALL_LAYOUT=amzn
LESS_TERMCAP_ue=
USER=root
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
SUDO_USER=ec2-user
EC2_HOME=/opt/aws/apitools/ec2
SUDO_UID=500
USERNAME=root
LESS_TERMCAP_us=
PATH=/sbin:/bin:/usr/sbin:/usr/local/bin:/opt/aws/bin:/usr/bin
MAIL=/var/spool/mail/ec2-user
PWD=/home/ec2-user
JAVA_HOME=/usr/lib/jvm/jre
AWS_CLOUDWATCH_HOME=/opt/aws/apitools/mon
LANG=en_US.UTF-8
SHLVL=1
SUDO_COMMAND=/bin/su
HOME=/root
AWS_PATH=/opt/aws
AWS_AUTO_SCALING_HOME=/opt/aws/apitools/as
LOGNAME=root
CVS_RSH=ssh
AWS_ELB_HOME=/opt/aws/apitools/elb
LESSOPEN=||/usr/bin/lesspipe.sh %s
AWS_RDS_HOME=/opt/aws/apitools/rds
SUDO_GID=500
LESS_TERMCAP_se=
_=/bin/env
OLDPWD=/home/ec2-user
## UPDATE FINAL ##
By adding
PATH=$PATH:/usr/bin;
export PATH
to the file /etc/profile, we were able to fix sudo -i for good
sudo su is still not working, but I guess I will just use **sudo -i
**
Thanks everybody!
Michelle Colin
(93 rep)
Jul 18, 2015, 05:08 AM
• Last activity: Jul 26, 2025, 03:40 PM
13
votes
3
answers
35910
views
How to see the total progress while copying the files
We know that if we give `--progress` parameter to `rsync` it will show the progress of files copied. But issue is that is shows the progress for each single file not total or overall progress. So how to see the Total progress of files copied.
We know that if we give
--progress
parameter to rsync
it will show the progress of files copied. But issue is that is shows the progress for each single file not total or overall progress.
So how to see the Total progress of files copied.
OmiPenguin
(4398 rep)
Mar 20, 2013, 05:21 PM
• Last activity: Jul 21, 2025, 03:34 AM
1
votes
3
answers
144
views
How to find the python command in a shell script?
Let's suppose that you have a super python 2&3 one-liner that you need to use in a shell script. On system A the `python` command works, but on system B you have to use `python3`, on system C you need to use `python3.12` or `python2`, etc... What would be a sensible way to check some, if not every,...
Let's suppose that you have a super python 2&3 one-liner that you need to use in a shell script.
On system A the
python
command works, but on system B you have to use python3
, on system C you need to use python3.12
or python2
, etc...
What would be a sensible way to check some, if not every, "python*" command name?
I want to avoid using a construct like this:
#!/bin/bash
if command -v python
then
python_exe=python
elif command -v python3
then
python_exe=python3
elif command -v python2
then
python_exe=python2
else
echo "python executable not found" >&2
exit 1
fi > /dev/null
"$python_exe" -c 'print("Hello world!");'
Fravadona
(1581 rep)
Mar 11, 2025, 08:13 PM
• Last activity: Jul 16, 2025, 01:38 PM
5
votes
1
answers
4836
views
How to start an application as GNOME would by command line?
How would I start an application (by launcher) the exact same way as GNOME would, in a command line interface? I want to set some environment variables. I know I can check the launcher file for the 'EXEC' command but for some reason that command makes my application crash; while when it's launched t...
How would I start an application (by launcher) the exact same way as GNOME would, in a command line interface? I want to set some environment variables.
I know I can check the launcher file for the 'EXEC' command but for some reason that command makes my application crash; while when it's launched through GNOME it works fine.
Jeroen
(827 rep)
Apr 1, 2014, 04:59 PM
• Last activity: Jul 12, 2025, 12:03 AM
0
votes
2
answers
12654
views
Pbrun not allowing to execute commands
Why do I get this when I execute `pbrun`. $ pbrun ls You are NOT allowed to use pbrun -h ls. Please try again without -h option. Host: xxxx Submithost: xxxx.abcd.xyz.com pbrun7.5.0-12[404]: Request rejected by pbmasterd on server1234.abcd.yyyy.com. I am actually trying to execute printer related com...
Why do I get this when I execute
pbrun
.
$ pbrun ls
You are NOT allowed to use pbrun -h ls.
Please try again without -h option.
Host: xxxx
Submithost: xxxx.abcd.xyz.com
pbrun7.5.0-12: Request rejected by pbmasterd on server1234.abcd.yyyy.com.
I am actually trying to execute printer related commands like lpshut
, lpadmin
, etc with pbrun
.
But it throws the exact error as above.
munish
(8227 rep)
May 2, 2014, 04:07 PM
• Last activity: Jul 7, 2025, 04:04 AM
4
votes
2
answers
1646
views
Find commands by partial name
Is there a way to get a list of all commands that match a specific (case insensitive) pattern? So for example, I know the command (which *might* be an alias) I'm looking for contains "diag" or "Diag" but I'm not sure of the actual command. I'm currently on Ubuntu with Bash but am asking specifically...
Is there a way to get a list of all commands that match a specific (case insensitive) pattern? So for example, I know the command (which *might* be an alias) I'm looking for contains "diag" or "Diag" but I'm not sure of the actual command.
I'm currently on Ubuntu with Bash but am asking specifically on this site because I'd love to learn of a way that's usable across various kinds of distros (e.g. I'll need this skill on CentOS and Manjaro later on too).
I've tried
man iag
hoping it would work the same as Powershell's help iag
but that doesn't work.
I've tried my [Google-fu](https://www.google.nl/search?q=find+command+by+partial+name) but that only seems to lead to explanations on how to find files by partial name of text inside files.
I've tried searching this SE site in various ways (e.g. (https://unix.stackexchange.com/search?q=+is%3Aq+find+partial+command) , (https://unix.stackexchange.com/search?q=+is%3Aq+command+partial+name)) but didn't find a duplicate of my question.
How do you find the exact name of a command if you can remember only part of it?
Jeroen
(147 rep)
Jul 23, 2017, 12:44 PM
• Last activity: May 28, 2025, 04:33 PM
6
votes
1
answers
2174
views
Please explain the output from the jobs command
When I ran `jobs` command I see the following output : [1] - Suspended ./startWebLogic.sh [2] + Suspended (signal) top 1. What does -/+ indicate in the second column ? 2. What is the difference between Suspended and Suspended(signal) ?
When I ran
jobs
command I see the following output :
- Suspended ./startWebLogic.sh
+ Suspended (signal) top
1. What does -/+ indicate in the second column ?
2. What is the difference between Suspended and Suspended(signal) ?
Geek
(6868 rep)
Jan 21, 2013, 05:18 PM
• Last activity: May 26, 2025, 09:42 AM
4
votes
2
answers
2394
views
How to print the failed command that caused the script's failure?
I'm using the `-e` flag. Usage: #!/bin/bash -e Explained: -e Exit immediately if a simple command (see SHELL GRAMMAR above) exits with a non-zero status When a command in the script fails, the script exits and doesn't continue to execute the rest of the commands, which is exactly what I want. But, t...
I'm using the
-e
flag.
Usage:
#!/bin/bash -e
Explained:
-e Exit immediately if a simple command (see SHELL GRAMMAR above) exits with a non-zero status
When a command in the script fails, the script exits and doesn't continue to execute the rest of the commands, which is exactly what I want.
But, the failure contains just the info that the failed command chooses to disclose.
Sometimes the failed command is very complicated, like a curl with many headers.
**How do I print the failed command? I mean, immediately after it failed.**
I know I can use the -x
bash flag but it will print all of the executed commands. I'd like to see just the failed one.
AlikElzin-kilaka
(571 rep)
Jan 23, 2023, 02:43 PM
• Last activity: May 22, 2025, 05:07 PM
0
votes
0
answers
42
views
Arch Linux - rsync succeeds but prsync does not work
I am moving a large number of files from one PC to another. The two PCs are in 192.168.0.0/24. I started by ryncing all music I had on my source PC to my new PC. ``` > rsync -P --recursive 192.168.0.201:/home/oldpc/Music /home/newpc/ oldpc@192.168.0.201's password: receiving incremental file list Mu...
I am moving a large number of files from one PC to another. The two PCs are in 192.168.0.0/24. I started by ryncing all music I had on my source PC to my new PC.
> rsync -P --recursive 192.168.0.201:/home/oldpc/Music /home/newpc/
oldpc@192.168.0.201's password:
receiving incremental file list
Music/helloworld.mp3
...
The command completed without issues. My /Documents
folder has over 10000 small files, which would consume a lot of time to transfer one by one. So I found
, which is able to rsync in parallel. I installed -pssh
from AUR. I took note of this manual and wrote my command.
> prsync -H 192.168.0.201 -l oldpc -p 32 -A -x "-r -P" /home/oldpc/Documents /home/newpc/
Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
Password:
[1] 16:14:44 [SUCCESS] 192.168.0.201
The command completed in a split second, with no file changes made on either end. I tried the same command a few more times, but it always failed.
> prsync -H 192.168.0.201 -l oldpc -p 32 -A -x "-r -P" /home/oldpc/Documents /home/newpc/
Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
Password:
[1] 16:15:20 [FAILURE] 192.168.0.201 Exited with error code 255
After waiting a few minutes, I tried one last time, where it succeeded and exited immediately once again without any actual file transfer. What is wrong with my prsync command?
Hyunbin Yoo
(175 rep)
May 17, 2025, 04:34 PM
2
votes
1
answers
155
views
Unix or Linux command to compare binary files
I'm looking for a command that compares binary files. Of course, I know about `diff`, but it is not very good at binaries. I have two files from a error-prone source (scratched dvd) which should be equal but aren't. (Well, realy more than two, and I get about 6 different md5sum out of 15 samples.) I...
I'm looking for a command that compares binary files.
Of course, I know about
diff
, but it is not very good at binaries.
I have two files from a error-prone source (scratched dvd) which should be equal but aren't.
(Well, realy more than two, and I get about 6 different md5sum out of 15 samples.)
I'm looking for a tool that lists the positions where the files differ.
---
In addition to the accepted answer, xxd looks good as it can also be used to change back edited hex-files to binary.
Gyro Gearloose
(455 rep)
May 9, 2025, 07:25 PM
• Last activity: May 14, 2025, 05:02 PM
33
votes
6
answers
132947
views
traceroute command: replacement or alternative
On recent Linux based operating systems there is no `ifconfig` and `traceroute`. Some functionality has been incorporated into the `ip` utility (see [here][1] for examples), but I have not found a replacement for the traceroute command. I know that I can do `yum install net-tools` or `yum install tr...
On recent Linux based operating systems there is no
ifconfig
and traceroute
. Some functionality has been incorporated into the ip
utility (see here for examples), but I have not found a replacement for the traceroute command.
I know that I can do yum install net-tools
or yum install traceroute
when I am on CentOS or RHEL but our servers come preinstalled without that command and while we are allowed to sudo certain commands installing additional software is always a problem
Marged
(801 rep)
Feb 15, 2019, 08:06 AM
• Last activity: May 6, 2025, 03:07 PM
0
votes
1
answers
89
views
Is there an official (re)source where is list it all the categories of commands with their respective set of commands?
Just being curious: **Question** * Is there an **official (re)source** where is list it all the categories of commands with their respective set of commands? Something like [Linux Foundation](https://www.linuxfoundation.org) for [Filesystem Hierarchy Standard **FHS**](https://refspecs.linuxfoundatio...
Just being curious:
**Question**
* Is there an **official (re)source** where is list it all the categories of commands with their respective set of commands?
Something like [Linux Foundation](https://www.linuxfoundation.org) for [Filesystem Hierarchy Standard **FHS**](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html)
I did do a research on Google with the
linux types of commands
search term but appears few information. But at the top from AI Overview
is shared as follows:
...
Navigation:
cd: Changes the current working directory.
pwd: Displays the full path of the current working directory.
...
Networking:
ping: Sends ICMP echo requests to check network connectivity.
ssh: Provides secure shell access to remote machines.
wget: Downloads files from the web.
curl: Transfers data using URLs.
...
Manuel Jordan
(2108 rep)
May 1, 2025, 04:25 PM
• Last activity: May 2, 2025, 10:23 AM
1
votes
2
answers
2378
views
Does the "watch" command put stress on a scheduler?
I have an account on a compute cluster which uses the SLURM scheduler. I have some jobs in the queue and I'm using the "watch" command to see their status: watch squeue -u myUserName Does constantly running this command put any significant stress on the scheduler?
I have an account on a compute cluster which uses the SLURM scheduler. I have some jobs in the queue and I'm using the "watch" command to see their status:
watch squeue -u myUserName
Does constantly running this command put any significant stress on the scheduler?
Niagara Falls
(19 rep)
May 25, 2019, 06:19 PM
• Last activity: Apr 10, 2025, 10:04 AM
0
votes
2
answers
269
views
Searching whole system for files with specific inode
I technically know how to do all these things, but combining it is problematic. Inode is saved in first line of text file (I can eventually read it directly from file), I need results saved to the same file. How can I do this?
I technically know how to do all these things, but combining it is problematic.
Inode is saved in first line of text file (I can eventually read it directly from file), I need results saved to the same file.
How can I do this?
Corporal Girrafe
(13 rep)
May 24, 2019, 12:06 PM
• Last activity: Mar 19, 2025, 06:03 PM
0
votes
2
answers
79
views
Kill current bash shell and start a new one with some command
is it possible to kill/exit the current `bash` shell and start a new one with some command? Something like kill -9 $PPID && bash -c echo 'I started new!' which does not work obviously.
is it possible to kill/exit the current
bash
shell and start a new one with some command?
Something like
kill -9 $PPID && bash -c echo 'I started new!'
which does not work obviously.
Juergen
(101 rep)
Mar 18, 2025, 09:37 AM
• Last activity: Mar 18, 2025, 03:56 PM
3
votes
3
answers
648
views
Tool for viewing top N items in stream
I'm looking for an existing Linux command-line tools that can accomplish the following: Consider there is an input stream `/dev/inputstream` which spews an infinite stream of data that looks like this: A A B A C Z A . . . **NOTE:** (Each line is one character from the alphabet). The tool is used in...
I'm looking for an existing Linux command-line tools that can accomplish the following:
Consider there is an input stream
/dev/inputstream
which spews an infinite stream of data that looks like this:
A
A
B
A
C
Z
A
.
.
.
**NOTE:** (Each line is one character from the alphabet).
The tool is used in the following fashion:
cat /dev/inputstream | tool
The output of the tool should be like the one from "top" command. It should be a continuously updated list of top N frequently occurring items.
Eg:
A -- 10 times
B -- 8 times
Z -- 7 times
C -- 2 times
D -- 1 time
If the stream were not infinite I could have accomplished this using sort
and uniq
.
Prashanth Ellina
(199 rep)
May 15, 2014, 06:18 PM
• Last activity: Mar 5, 2025, 06:33 AM
7
votes
2
answers
1926
views
Why does Debian not include POSIX-specified commands like bc and ed by default?
[POSIX.1-2001](https://pubs.opengroup.org/onlinepubs/009695399/) [Utilities](https://pubs.opengroup.org/onlinepubs/009695399/idx/utilities.html) and [POSIX.1-2008](https://pubs.opengroup.org/onlinepubs/9699919799/) [Utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) both...
[POSIX.1-2001](https://pubs.opengroup.org/onlinepubs/009695399/) [Utilities](https://pubs.opengroup.org/onlinepubs/009695399/idx/utilities.html) and [POSIX.1-2008](https://pubs.opengroup.org/onlinepubs/9699919799/) [Utilities](https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html) both list the commands
bc
and ed
to be part of POSIX.
Yet, in a brand new Debian installation (version 10 for example), these commands are missing by default:
$ bc
bash: bc: command not found
$ ed
bash: ed: command not found
Why does Debian not include these commands by default? Of course, I can install them with and I did that.
apt-get install bc ed
The bc
binary is only 87K in size. The entire package including the man page and documentation is only 209K in size.
Similarly the ed
binary is only 55K in size. The entire package is only 93K in size.
What good reason is there not to include these tiny packages even though they are specified in POSIX?
Lone Learner
(170 rep)
Sep 12, 2020, 07:00 AM
• Last activity: Feb 23, 2025, 08:08 AM
0
votes
1
answers
76
views
cpulimit: detect failure / exit status in Linux
I'm using `cpulimit` in a Bash script to run a certain command (ffmpeg) with a limited CPU usage, but I want to know if the command fails. But when the command(ffmpeg) fails with any error, cpulimit still exists with exit status 0. What should I do? My cpulimit command: `cpulimit -l 300 -f -- ffmpeg...
I'm using
cpulimit
in a Bash script to run a certain command (ffmpeg) with a limited CPU usage, but I want to know if the command fails. But when the command(ffmpeg) fails with any error, cpulimit still exists with exit status 0. What should I do?
My cpulimit command: cpulimit -l 300 -f -- ffmpeg ...
CPUlimit version 3.0
OS: Ubuntu with Linux 6.8.0
Note: cpulimit does not work on forks of the given command, unless I pass --monitor-forks flag, which the manual says is a bad idea specially in scripts:
> -m, --monitor-forks watch and throttle child processes of the target process Warning: It is usually a bad idea to use this flag,
> espe‐ cially on a shell script. The commands in the script will each
> spawn a process which will, in turn, spawn more copies of this program
> to throttle them, bogging down the system. Also, it is possible for a
> child process to die and for its PID to be assigned to another
> program. When this happens quickly it can cause cpulimit to target the
> new, unin‐ tended process before the old information has had a chance
> to be flushed out. Only use the monitor-forks option in specific
> cases, ideally on machines without a lot of new processes being
> spawned.
saeedgnu
(153 rep)
Feb 9, 2025, 07:04 AM
• Last activity: Feb 9, 2025, 08:48 AM
Showing page 1 of 20 total questions