Tag Archives: Linux C/C++

[Solved] shc -f xxx.sh shc: invalid first line in scrip

shc -f xxx.sh shc: invalid first line in scrip
Problem: The following error occurs when running shc
Code: $ shc -f test1.sh shc: invalid first line in script
Analysis: The script works fine
$cat test1.sh
echo “hello”
cal
Code:
$ shc -f test1.sh
shc: invalid first line in script: echo “hello”
shc: Success
Reason:

You have to put the sha-bang (e.g. #!/bin/bash) at the beginning of the script, since shc need to know which shell is using. Here is an excerpt from the manual page:

Explanation:
Add to the first line of the script ( #! /bin/bash)
Pro-tested available!

CentOS execution command error: – bash: fork: cannot allocate memory processing / viewing process number

Contents of articles

Error reported by CentOS when executing command: – bash: fork: cannot allocate memory

Error reported by CentOS when executing command: – bash: fork: cannot allocate memory

Background:
executing any command will report – bash: fork: cannot allocate memory, but there is still a lot of free memory.

Problem analysis:
the reason is that the number of processes is full, which exceeds the default value set by the system

View the maximum number of processes

sysctl kernel.pid_max

View the number of processes

ps -eLf | wc -l

You will find that the number of all processes is almost more than the default number of processes

After modifying the maximum number of processes, the system can recover without restarting the process.

echo 1000000 > /proc/sys/kernel/pid_max

Permanent effect

echo "kernel.pid_max=1000000 " >> /etc/sysctl.conf
sysctl -p