taskset openssl

Use the taskset command to let the process run on the specified CPU,

Encrypt and decrypt large files with openssl

generate a symmetric key

openssl rand -base64 32 > key.bin

Encrypt large files with symmetric keys

openssl enc -aes-256-cbc -salt -in myLargeFile.xml -out myLargeFile.xml.enc -pass file:./key.bin

Encrypt the symmetric key for easy sending to others

openssl rsautl -encrypt -inkey public.pem -pubin -in key.bin -out key.bin.enc

Destroy large unencrypted files so no one can find it

shred -u key.bin

Send encrypted symmetric keys and encrypted large files to others

Others use the private key to decrypt the symmetric key

openssl rsautl -decrypt -inkey private.pem -in key.bin.enc -out key.bin

Large files can now be decrypted using symmetric keys

openssl enc -d -aes-256-cbc -in myLargeFile.xml.enc -out myLargeFile.xml -pass file:./key.bin

Introduction to tasksets

Taskset is a task that can assign a process task to run on a certain CPU

A process can be bound to a CPU core through the taskset command, so that it runs only on the bound CPU core, which can be used for CPU tuning of the process, and a process running on the cloud server can be specified Work on a certain CPU.

View the number of CPU cores of the cloud server

操作步骤
执行如下命令,查看云服务器CPU核数。
cat /proc/cpuinfo

关于CPU的核心参数说明:
processor:指明第几个CPU处理器
cpu cores:指明每个处理器的核心数

执行以下命令,获取进程状态(以下操作以进程test.sh为例,对应的pid为23989)
ps aux | grep test.sh

执行以下命令,查看进程当前运行在哪个CPU上。
taskset -p 进程号

例如:taskset -p 23989
显示的是十进制数字1,转换为2进制为1。

执行以下命令,指定进程运行在第二个CPU(CPU1)上。
taskset -pc 1 进程号

例如:taskset -pc 1 23989

也可以使用如下命令在启动程序时绑定CPU(启动时绑定到第二个CPU)上。
taskset -c 1 ./test.sh&

*说明:
CPU的标号是从0开始的,所以CPU1表示第二个CPU(第一个CPU的标号是0),这样就把应用程序test.sh绑定到了CPU1上运行
语法格式:taskset [options] -p [mask] pid
参数选项:
-a, --all-tasks 操作所有的任务线程
-p, --pid 操作已存在的pid
-c, --cpu-list 通过列表显示方式设置CPU(逗号相隔)
-V, --version 输出版本信息

Guess you like

Origin blog.csdn.net/weixin_45720992/article/details/131832610