我想知道通过命令行将磁盘置于待机模式的命令是什么。我的目标是制作一个处理这种情况的特定脚本。
提前致谢。
我有一个生产 vm U16.04 LTS,它破坏了 apt-get 和/boot
带有各种内核的完整目录。
apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
linux-headers-4.4.0-138 linux-headers-4.4.0-138-generic linux-headers-4.4.0-139 linux-headers-4.4.0-139-generic
linux-headers-4.4.0-141 linux-headers-4.4.0-141-generic linux-headers-4.4.0-142 linux-headers-4.4.0-142-generic
linux-headers-4.4.0-145 linux-headers-4.4.0-145-generic linux-headers-4.4.0-148 linux-headers-4.4.0-148-generic
linux-headers-4.4.0-150 linux-headers-4.4.0-150-generic linux-headers-4.4.0-157 linux-headers-4.4.0-157-generic
linux-image-4.4.0-138-generic linux-image-4.4.0-139-generic linux-image-4.4.0-141-generic linux-image-4.4.0-142-generic
linux-image-4.4.0-145-generic linux-image-4.4.0-148-generic linux-image-4.4.0-150-generic linux-image-4.4.0-157-generic
linux-image-extra-4.4.0-138-generic linux-image-extra-4.4.0-139-generic linux-image-extra-4.4.0-141-generic
linux-image-extra-4.4.0-142-generic linux-modules-4.4.0-145-generic linux-modules-4.4.0-148-generic
linux-modules-4.4.0-150-generic linux-modules-4.4.0-157-generic linux-modules-extra-4.4.0-145-generic
linux-modules-extra-4.4.0-148-generic linux-modules-extra-4.4.0-150-generic linux-modules-extra-4.4.0-157-generic
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
linux-generic linux-headers-4.4.0-171 linux-headers-4.4.0-171-generic linux-headers-generic linux-image-4.4.0-157-generic
linux-image-4.4.0-171-generic linux-image-generic linux-modules-4.4.0-157-generic linux-modules-4.4.0-171-generic
linux-modules-extra-4.4.0-171-generic
Suggested packages:
fdutils linux-doc-4.4.0 | linux-source-4.4.0 linux-tools
Recommended packages:
thermald
The following NEW packages will be installed:
linux-headers-4.4.0-171 linux-headers-4.4.0-171-generic linux-image-4.4.0-157-generic linux-image-4.4.0-171-generic
linux-modules-4.4.0-157-generic linux-modules-4.4.0-171-generic linux-modules-extra-4.4.0-171-generic
The following packages will be upgraded:
linux-generic linux-headers-generic linux-image-generic
3 upgraded, 7 newly installed, 0 to remove and 199 not upgraded.
7 not fully installed or removed.
Need to get 66.3 MB/85.2 MB of archives.
After this operation, 369 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirror.hetzner.de/ubuntu/packages xenial-updates/main amd64 linux-modules-4.4.0-171-generic amd64 4.4.0-171.200 [12.0 MB]
Get:2 http://mirror.hetzner.de/ubuntu/packages xenial-updates/main amd64 linux-image-4.4.0-171-generic amd64 4.4.0-171.200 [6,938 kB]
Get:3 http://mirror.hetzner.de/ubuntu/packages xenial-updates/main amd64 linux-modules-extra-4.4.0-171-generic amd64 4.4.0-171.200 [36.6 MB]
Get:4 http://mirror.hetzner.de/ubuntu/packages xenial-updates/main amd64 linux-generic amd64 4.4.0.171.179 [1,790 B]
Get:5 http://mirror.hetzner.de/ubuntu/packages xenial-updates/main amd64 linux-image-generic amd64 4.4.0.171.179 [2,442 B]
Get:6 http://mirror.hetzner.de/ubuntu/packages xenial-updates/main amd64 linux-headers-4.4.0-171 all 4.4.0-171.200 [10.0 MB]
Get:7 http://mirror.hetzner.de/ubuntu/packages xenial-updates/main amd64 linux-headers-4.4.0-171-generic amd64 4.4.0-171.200 [798 kB]
Get:8 http://mirror.hetzner.de/ubuntu/packages xenial-updates/main amd64 linux-headers-generic amd64 4.4.0.171.179 [2,282 B]
Fetched 66.3 MB in 1s (36.3 MB/s)
Selecting previously unselected package linux-modules-4.4.0-171-generic.
(Reading database ... 415318 files and directories currently installed.)
Preparing to unpack .../linux-modules-4.4.0-171-generic_4.4.0-171.200_amd64.deb ...
Unpacking linux-modules-4.4.0-171-generic (4.4.0-171.200) ...
dpkg: error processing archive /var/cache/apt/archives/linux-modules-4.4.0-171-generic_4.4.0-171.200_amd64.deb (--unpack):
cannot copy extracted data for './boot/System.map-4.4.0-171-generic' to '/boot/System.map-4.4.0-171-generic.dpkg-new': failed to write (No space left on device)
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Selecting previously unselected package linux-image-4.4.0-171-generic.
Preparing to unpack .../linux-image-4.4.0-171-generic_4.4.0-171.200_amd64.deb ...
Unpacking linux-image-4.4.0-171-generic (4.4.0-171.200) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-4.4.0-171-generic_4.4.0-171.200_amd64.deb (--unpack):
cannot copy extracted data for './boot/vmlinuz-4.4.0-171-generic' to '/boot/vmlinuz-4.4.0-171-generic.dpkg-new': failed to write (No space left on device)
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
cd /boot && ls
abi-4.4.0-138-generic config-4.4.0-154-generic retpoline-4.4.0-138-generic System.map-4.4.0-154-generic
abi-4.4.0-139-generic grub retpoline-4.4.0-139-generic vmlinuz-4.4.0-138-generic
abi-4.4.0-141-generic initrd.img-4.4.0-138-generic retpoline-4.4.0-141-generic vmlinuz-4.4.0-139-generic
abi-4.4.0-142-generic initrd.img-4.4.0-139-generic retpoline-4.4.0-142-generic vmlinuz-4.4.0-141-generic
config-4.4.0-138-generic initrd.img-4.4.0-141-generic System.map-4.4.0-138-generic vmlinuz-4.4.0-142-generic
config-4.4.0-139-generic initrd.img-4.4.0-142-generic System.map-4.4.0-139-generic vmlinuz-4.4.0-143-generic
config-4.4.0-141-generic initrd.img-4.4.0-143-generic System.map-4.4.0-141-generic vmlinuz-4.4.0-145-generic
config-4.4.0-142-generic initrd.img-4.4.0-145-generic System.map-4.4.0-142-generic vmlinuz-4.4.0-148-generic
config-4.4.0-143-generic initrd.img-4.4.0-148-generic System.map-4.4.0-143-generic vmlinuz-4.4.0-150-generic
config-4.4.0-145-generic initrd.img-4.4.0-150-generic System.map-4.4.0-145-generic vmlinuz-4.4.0-151-generic
config-4.4.0-148-generic initrd.img-4.4.0-151-generic System.map-4.4.0-148-generic vmlinuz-4.4.0-154-generic
config-4.4.0-150-generic initrd.img-4.4.0-154-generic System.map-4.4.0-150-generic
config-4.4.0-151-generic lost+found System.map-4.4.0-151-generic
uname -r
4.4.0-143-generic
df -h
Filesystem Size Used Avail Use% Mounted on
udev 63G 0 63G 0% /dev
tmpfs 13G 1.3G 12G 11% /run
/dev/md2 1.8T 714G 953G 43% /
tmpfs 63G 0 63G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 63G 0 63G 0% /sys/fs/cgroup
/dev/md1 488M 486M 0 100% /boot
/dev/sdc1 1.8T 68M 1.7T 1% /var/lib/mysql-extra-disk
tmpfs 13G 0 13G 0% /run/user/0
tmpfs 13G 0 13G 0% /run/user/111
rm
如果不安全,我不想使用任何命令。任何帮助表示赞赏。
编辑:
删除:
root@Ubuntu-1604-xenial-64-minimal-no-hwe /boot # rm abi-4.4.0-138-generic
root@Ubuntu-1604-xenial-64-minimal-no-hwe /boot # rm abi-4.4.0-139-generic
root@Ubuntu-1604-xenial-64-minimal-no-hwe /boot # rm initrd.img-4.4.0-138-generic
root@Ubuntu-1604-xenial-64-minimal-no-hwe /boot # rm initrd.img-4.4.0-139-generic
root@Ubuntu-1604-xenial-64-minimal-no-hwe /boot # rm retpoline-4.4.0-138-generic
root@Ubuntu-1604-xenial-64-minimal-no-hwe /boot # rm retpoline-4.4.0-139-generic
root@Ubuntu-1604-xenial-64-minimal-no-hwe /boot # rm System.map-4.4.0-138-generic
root@Ubuntu-1604-xenial-64-minimal-no-hwe /boot # rm System.map-4.4.0-139-generic
root@Ubuntu-1604-xenial-64-minimal-no-hwe /boot # rm vmlinuz-4.4.0-138-generic
root@Ubuntu-1604-xenial-64-minimal-no-hwe /boot # rm vmlinuz-4.4.0-139-generic
并apt-get install -f
工作。谢谢!
我有一个旧但很酷的 MB Asus RAMPAGE Extreame II。突然系统将其关闭,然后在启动时我收到警告。传感器得到了这些数字:
poweruser@home:~$ sensors
atk0110-acpi-0
Adapter: ACPI interface
3.3V Voltage: +3.33 V (min = +2.97 V, max = +3.63 V)
5V Voltage: +4.95 V (min = +4.50 V, max = +5.50 V)
12V Voltage: +12.31 V (min = +10.20 V, max = +13.80 V)
CPU Voltage: +1.04 V (min = +0.80 V, max = +1.80 V)
CPU PLL Voltage: +1.81 V (min = +1.50 V, max = +2.00 V)
QPI/DRAM Core Voltage: +1.19 V (min = +0.80 V, max = +1.50 V)
IOH Voltage: +1.14 V (min = +0.90 V, max = +1.35 V)
IOH PCIE Voltage: +1.51 V (min = +1.20 V, max = +1.80 V)
ICH Voltage: +1.11 V (min = +0.90 V, max = +1.35 V)
ICH PCIE Voltage: +1.51 V (min = +1.20 V, max = +1.80 V)
DRAM Bus Voltage: +1.48 V (min = +1.40 V, max = +1.90 V)
CPU FAN Speed: 692 RPM (min = 600 RPM, max = 7200 RPM)
CHA_FAN1 FAN Speed: 0 RPM (min = 600 RPM, max = 7200 RPM)
CHA_FAN2 FAN Speed: 0 RPM (min = 600 RPM, max = 7200 RPM)
CHA_FAN3 FAN Speed: 0 RPM (min = 600 RPM, max = 7200 RPM)
PWR_FAN FAN Speed: 0 RPM (min = 600 RPM, max = 7200 RPM)
OPT_FAN1 FAN Speed: 1213 RPM (min = 600 RPM, max = 7200 RPM)
OPT_FAN2 FAN Speed: 0 RPM (min = 600 RPM, max = 7200 RPM)
OPT_FAN3 FAN Speed: 0 RPM (min = 600 RPM, max = 7200 RPM)
CPU Temperature: +44.0°C (high = +60.0°C, crit = +65.0°C)
MB Temperature: +40.0°C (high = +45.0°C, crit = +55.0°C)
SB Temperature: +57.0°C (high = +65.0°C, crit = +65.0°C)
NB Temperature: +99.0°C (high = +80.0°C, crit = +80.0°C)
OPT_FAN1 Temperature: +0.0°C (high = +45.0°C, crit = +45.0°C)
OPT_FAN2 Temperature: +0.0°C (high = +45.0°C, crit = +45.0°C)
OPT_FAN3 Temperature: +0.0°C (high = +45.0°C, crit = +45.0°C)
我卸下了散热器,清洁并添加了新的导热膏,但没有任何变化。有任何想法吗? 照片
我写了一个脚本:
#!/bin/bash
dir=/opt/bla/myfiles
# Check disk usage usep=$(df -H | grep /dev/sda3 | awk '{print $5}' | cut -d '%' -f1) if [ $usep -ge 90 ]; then
echo "$(date) Running out of space in /dev/sda3 with $usep percent - so deleting action is taking!" >> /var/log/messages &&
find $dir/releases/* -mtime +3 -exec rm {} \; else
echo "$(date) Disk space is $usep percent - no action required!" /var/log/messages fi
效果很好。但我现在需要更高级的方法。如您所见,它会删除 dir 中超过 3 天的所有文件。我有很多版本,例如:1.31.1 1.31.2 1.31.3 ...... 1.31.150 1.32.1 1.32.2
等等。我想从主要版本 1.31/1.32 中删除除最后一个版本之外的所有版本。如何?它不能是静态名称,因为有一天它会是 2.32.150
ls -l
total 520
drwxr-xr-x 2 jenkins jenkins 4096 Jun 23 15:45 0.0.31-SNAPSHOT
drwxr-xr-x 2 jenkins jenkins 4096 Jun 23 15:45 1.33.0.100-RELEASE
drwxr-xr-x 2 jenkins jenkins 4096 Jun 23 15:45 1.33.0.101-RELEASE
drwxr-xr-x 2 jenkins jenkins 4096 Jun 8 11:00 1.33.0.58-RELEASE
drwxr-xr-x 2 jenkins jenkins 4096 Jun 8 11:00 1.33.0.59-RELEASE
drwxr-xr-x 2 jenkins jenkins 4096 Jun 8 11:00 1.33.0.64-RELEASE
drwxr-xr-x 2 jenkins jenkins 4096 Jun 8 11:00 1.33.0.66-RELEASE
任何想法,谢谢!
我编写了某种脚本,它从数组中获取字符串并在文件中重放它。这里的问题是特殊字符不会通过。有任何想法吗?
#!/bin/bash/
NewParameters=(
scservice.memberServiceEndpoint="http://mywebhere.com"
scservice.memberServiceConpoint="http://example.com"
play.modules.disabled += "play.data.format.FormattersModule"
)
file=/home/conf.conf
for i in "${NewParameters[@]}"
do
before=$(printf "%s\n" $i | awk -F'=' '{print $1}')
after=$(printf "%s\n" $i | awk -F'=' '{print $2}')
sed -i "s@$before=.*@$before=$after@g" $file
done
输出结果:
scservice.memberServiceEndpoint=http://mywebhere.com
scservice.memberServiceConpoint=http://example.com
play.modules.disabled += play.data.format.FormattersModule