Bash
Error pip install mysqlclient on MacOSX
If you have the similar issue as below ERROR: Command errored out with exit status 1: command: /.../bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/53/l74q51892zjgsql64hkvhw180000gn/T/pip-install-e_x8dx0d/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/53/l74q51892zjgsql64hkvhw180000gn/T/pip-install-e_x8dx0d/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/53/l74q51892zjgsql64hkvhw180000gn/T/pip-wheel-8pw_7779 cwd: /private/var/folders/53/l74q51892zjgsql64hkvhw180000gn/T/pip-install-e_x8dx0d/mysqlclient/ Complete output (30 lines): running bdist_wheel running build running build_py creating build creating build/lib.macosx-10.9-x86_64-3.7 creating build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/_exceptions.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/compat.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/connections.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/converters.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/cursors.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/release.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb copying MySQLdb/times.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb creating build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-x86_64-3.7/MySQLdb/constants running build_ext building 'MySQLdb._mysql' extension creating build/temp.macosx-10.9-x86_64-3.7 creating build/temp.macosx-10.9-x86_64-3.7/MySQLdb gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 -I/usr/local/Cellar/mysql/8.0.19/include/mysql -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.macosx-10.9-x86_64-3.7/MySQLdb/_mysql.o gcc -bundle -undefined dynamic_lookup -arch x86_64 -g build/temp.macosx-10.9-x86_64-3.7/MySQLdb/_mysql.o -L/usr/local/Cellar/mysql/8.0.19/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.9-x86_64-3.7/MySQLdb/_mysql.cpython-37m-darwin.so ld: library not found for -lssl clang: error: linker command failed with exit code 1 (use -v to see invocation) error: command 'gcc' failed with exit status 1 ---------------------------------------- ERROR: Failed building wheel for mysqlclient The easiest and fastest solution to try is: Update your ~/.bash_profile or ~/.bashrc and add this line: export PATH="/usr/local/opt/openssl/bin:$PATH" Reload ~/.bash_profile or ~/.bashrc source ~/.bash_profileTransfer files from or to linux and unix server
SCP scp command will copy and replace everything from source to destination. Copy files recursively from local to server: scp -rp ~/Downloads user@server.com:/path Copy files recursively from server to local: scp -rp user@server.com:/path ~/Downloads RSYNC rsync will copy and check and compare files before copying files from source to destination. Copy files recursively from local to server: rsync -av ~/Downloads user@server.com:/path Copy files recursively from server to local: rsync -av user@server.com:/path ~/DownloadsHow to upgrade all Python packages using pip
There's no built-in command or parameter yet, but you can use: pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U In older version of pip, you can use: pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U There are infinite potential variations for this. I'm trying to keep this answer short and simple, but please suggest variations in the comments!rsyslog: Log messages spamming console
Remove Emergency Messages to all users This selector-action states "Emergency messages often go to all users currently online to notify them that something strange is happening with the system. To specify this wall(1)-feature use an ":omusrmsg:*"." Comment this line out. Here's are the steps: Stop rsyslog service - Due to your console being flooded by messages, you will have a hard time executing commands so I suggest you stop the service first. service rsyslog stop Edit rsyslog configuration file /etc/rsyslog.conf vim /etc/rsyslog.conf Find the line: *.emerg :omusrmsg:* Comment out the whole line and save the file Start the rsyslog service again service rsyslog start Check and fix configuration file (if there's any) If the above steps still didn't resolve the issue, maybe there's some other problems from the configuration file that's causing it to ignore the configurations set. You can try following these steps to find out and fix the configuration issue: Stop rsyslog service - Due to your console being flooded by messages, you will have a hard time executing commands so I suggest you stop the service first. service rsyslog stop Check rsyslog status service rsyslog status It should return something like this: Redirecting to /bin/systemctl status rsyslog.service ● rsyslog.service - System Logging Service Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled) Active: inactive (dead) since Thu 2020-04-23 11:52:15 +08; 7s ago Docs: man:rsyslogd(8) http://www.rsyslog.com/doc/ Process: 22063 ExecStart=/usr/sbin/rsyslogd -n $SYSLOGD_OPTIONS (code=exited, status=0/SUCCESS) Main PID: 22063 (code=exited, status=0/SUCCESS) Apr 23 11:50:23 site.com systemd[1]: Starting System Logging Service... Apr 23 11:50:23 site.com rsyslogd[22063]: [origin software="rsyslogd" swVersion="8.24.0-34.el7" x-pid="22063" x-info="http://www.rsyslog.com"] start Apr 23 11:50:23 site.com rsyslogd[22063]: action '*' treated as ':omusrmsg:*' - please use ':omusrmsg:*' syntax instead, '*' will not be supported in the futu...m/e/2184 ] Apr 23 11:50:23 site.com systemd[1]: Started System Logging Service. Apr 23 11:50:23 site.com rsyslogd[22063]: error during parsing file /etc/rsyslog.conf, on or before line 95: warnings occured in file '/etc/rsyslog.conf' arou...m/e/2207 ] Apr 23 11:50:23 site.com rsyslogd[22063]: invalid character in selector line - ';template' expected [v8.24.0-34.el7] Apr 23 11:50:23 site.com rsyslogd[22063]: error during parsing file /etc/rsyslog.conf, on or before line 95: errors occured in file '/etc/rsyslog.conf' around...m/e/2207 ] Apr 23 11:52:15 site.com systemd[1]: Stopping System Logging Service... Apr 23 11:52:15 site.com rsyslogd[22063]: [origin software="rsyslogd" swVersion="8.24.0-34.el7" x-pid="22063" x-info="http://www.rsyslog.com"] exiting on signal 15. Apr 23 11:52:15 site.com systemd[1]: Stopped System Logging Service. Hint: Some lines were ellipsized, use -l to show in full. Analyze the status messages to see which line to fix. On this case, I have an error on line 95 of /etc/rsyslog.conf. Edit and fix the configuration file according to the status message. Start the service again service rsyslog startSchedule command using at command
Creating commands Type in your terminal: at [schedule] e.g.: at 10:30 am Then inside the at command you can type in your commands like: at> php /var/www/html/yii-application/yii job/my-custom-job param1 param2 Then when you are done adding commands, presst CTRL+D Deleting commands If you don't know yet the schedule id, you can execute atq It will show you the list of scheduled commands like below: job 12 at Wed Feb 20 01:00:00 2019 To see the actual command you can execute at -c 12 To delete the schedule, simply use atrm command with the schedule id like this: atrm 12 And just in case you were thinking how to close the command that is already running, atrm will not stop the command. Instead you need to kill manually. In your terminal, run: ps -ef | grep 'YOUR_COMMAND' It will return something like this: UID PID PPID C STIME TTY TIME CMD root 361 1 0 Oct19 ? 00:00:04 YOUR_COMMAND Get the PID to kill the command kill 361Run SSH command in background
Do you have to run a big command that requires 30 minutes, 1 hour, 2 hours or 6 hours? Unfortunately SSH connections times out. Here's a simple trick on how to run a ssh command in the background so you can run your command and maybe sleep for a while or continue with your life. In your terminal, run: nohup YOUR_COMMAND your_command_parameters > my.log 2>&1 & And just in case you were thinking how to close the command, in your terminal, run: ps -ef | grep 'YOUR_COMMAND' It will return something like this: UID PID PPID C STIME TTY TIME CMD root 361 1 0 Oct19 ? 00:00:04 YOUR_COMMAND Get the PID to kill the command kill 361