博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux常用命令(配置查看,定时任务)
阅读量:5169 次
发布时间:2019-06-13

本文共 10005 字,大约阅读时间需要 33 分钟。

1.查看所有待挂载设备信息

fdisk -l

# fdisk -lDisk /dev/sda: 120.0 GB, 120034123776 bytes255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00002f03   Device Boot      Start         End      Blocks   Id  System/dev/sda1   *        2048   226170879   113084416   83  Linux/dev/sda2       226172926   234440703     4133889    5  Extended/dev/sda5       226172928   234440703     4133888   82  Linux swap / SolarisDisk /dev/sdb: 1000.2 GB, 1000204886016 bytes255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytesDisk identifier: 0x3025e656   Device Boot      Start         End      Blocks   Id  System/dev/sdb1            2048   614402047   307200000    7  HPFS/NTFS/exFAT/dev/sdb2       614402048  1228802047   307200000    7  HPFS/NTFS/exFAT/dev/sdb3      1228802048  1953519615   362358784    7  HPFS/NTFS/exFAT
View Code

  

2.查看cpu信息

cat /proc/cpuinfo

processor    : 0vendor_id    : GenuineIntelcpu family    : 6model        : 60model name    : Intel(R) Core(TM) i5-4670 CPU @ 3.40GHzstepping    : 3microcode    : 0x19cpu MHz        : 3443.429cache size    : 6144 KBphysical id    : 0siblings    : 4core id        : 0cpu cores    : 4apicid        : 0initial apicid    : 0fdiv_bug    : nof00f_bug    : nocoma_bug    : nofpu        : yesfpu_exception    : yescpuid level    : 13wp        : yesflags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtmbogomips    : 6796.22clflush size    : 64cache_alignment    : 64address sizes    : 39 bits physical, 48 bits virtualpower management:processor    : 1vendor_id    : GenuineIntelcpu family    : 6model        : 60model name    : Intel(R) Core(TM) i5-4670 CPU @ 3.40GHzstepping    : 3microcode    : 0x19cpu MHz        : 3399.601cache size    : 6144 KBphysical id    : 0siblings    : 4core id        : 1cpu cores    : 4apicid        : 2initial apicid    : 2fdiv_bug    : nof00f_bug    : nocoma_bug    : nofpu        : yesfpu_exception    : yescpuid level    : 13wp        : yesflags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtmbogomips    : 6796.22clflush size    : 64cache_alignment    : 64address sizes    : 39 bits physical, 48 bits virtualpower management:processor    : 2vendor_id    : GenuineIntelcpu family    : 6model        : 60model name    : Intel(R) Core(TM) i5-4670 CPU @ 3.40GHzstepping    : 3microcode    : 0x19cpu MHz        : 3400.000cache size    : 6144 KBphysical id    : 0siblings    : 4core id        : 2cpu cores    : 4apicid        : 4initial apicid    : 4fdiv_bug    : nof00f_bug    : nocoma_bug    : nofpu        : yesfpu_exception    : yescpuid level    : 13wp        : yesflags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtmbogomips    : 6796.22clflush size    : 64cache_alignment    : 64address sizes    : 39 bits physical, 48 bits virtualpower management:processor    : 3vendor_id    : GenuineIntelcpu family    : 6model        : 60model name    : Intel(R) Core(TM) i5-4670 CPU @ 3.40GHzstepping    : 3microcode    : 0x19cpu MHz        : 3400.000cache size    : 6144 KBphysical id    : 0siblings    : 4core id        : 3cpu cores    : 4apicid        : 6initial apicid    : 6fdiv_bug    : nof00f_bug    : nocoma_bug    : nofpu        : yesfpu_exception    : yescpuid level    : 13wp        : yesflags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtmbogomips    : 6796.22clflush size    : 64cache_alignment    : 64address sizes    : 39 bits physical, 48 bits virtualpower management:
View Code

 

3.查看内存信息

cat /proc/meminfo

cat /proc/meminfoMemTotal:        4090736 kBMemFree:         1628156 kBMemAvailable:    2270864 kBBuffers:            7984 kBCached:           991184 kBSwapCached:            0 kBActive:          1458132 kBInactive:         838020 kBActive(anon):    1102336 kBInactive(anon):   377500 kBActive(file):     355796 kBInactive(file):   460520 kBUnevictable:          32 kBMlocked:              32 kBHighTotal:       3227012 kBHighFree:        1084212 kBLowTotal:         863724 kBLowFree:          543944 kBSwapTotal:       4133884 kBSwapFree:        4133884 kBDirty:               308 kBWriteback:             0 kBAnonPages:       1297060 kBMapped:           605736 kBShmem:            182856 kBSlab:              53976 kBSReclaimable:      30016 kBSUnreclaim:        23960 kBKernelStack:        4592 kBPageTables:        16260 kBNFS_Unstable:          0 kBBounce:                0 kBWritebackTmp:          0 kBCommitLimit:     6179252 kBCommitted_AS:    6168352 kBVmallocTotal:     122880 kBVmallocUsed:       52824 kBVmallocChunk:      61204 kBAnonHugePages:    520192 kBHugePages_Total:       0HugePages_Free:        0HugePages_Rsvd:        0HugePages_Surp:        0Hugepagesize:       2048 kBDirectMap4k:      378872 kBDirectMap2M:      530432 kB
View Code

  

4.硬盘速度测试

hdparm -Tt /dev/sda1

# hdparm -Tt /dev/sda1/dev/sda1: Timing cached reads:   22580 MB in  2.00 seconds = 11305.77 MB/sec Timing buffered disk reads: 1094 MB in  3.01 seconds = 363.90 MB/sec

 

5.cron执行定时任务

crontab -l查看定时任务列表

crontab -e 编辑定时任务

 

5.1简单的定时任务编辑示范

crontab -e

# Edit this file to introduce tasks to be run by cron.# # Each task to run has to be defined through a single line# indicating with different fields when the task will be run# and what command to run for the task# # To define the time you can provide concrete values for# minute (m), hour (h), day of month (dom), month (mon),# and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system# daemon's notion of time and timezones.# # Output of the crontab jobs (including errors) is sent through# email to the user the crontab file belongs to (unless redirected).# # For example, you can run a backup of all your user accounts# at 5 a.m every week with:# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/# # For more information see the manual pages of crontab(5) and cron(8)# # m h  dom mon dow   command # ##每隔一分钟输出时间到文件
*/2 * * * * echodate >> $HOME>test.txt

 

 5.2 查看定时任务列表

crontab -l

# crontab -l# Edit this file to introduce tasks to be run by cron.# # Each task to run has to be defined through a single line# indicating with different fields when the task will be run# and what command to run for the task# # To define the time you can provide concrete values for# minute (m), hour (h), day of month (dom), month (mon),# and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system# daemon's notion of time and timezones.# # Output of the crontab jobs (including errors) is sent through# email to the user the crontab file belongs to (unless redirected).# # For example, you can run a backup of all your user accounts# at 5 a.m every week with:# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/# # For more information see the manual pages of crontab(5) and cron(8)# # m h  dom mon dow   command*/2 * * * * date >> $HOME>test.txt

5.3查看定时任务运行效果

tail -f ~/test.txt

tail -f ~/test.txt2015年 10月 02日 星期五 10:24:01 CST2015年 10月 02日 星期五 10:26:01 CST2015年 10月 02日 星期五 10:28:01 CST2015年 10月 02日 星期五 10:30:01 CST

5.4 crontab补充

 5.4.1 开启corntab 服务  /etc/init.d/cron start

 5.4.2 开机启动corntab

 vim /etc/rc.local 添加需要启动的服务

 例如 

  
#!/bin/sh -e## rc.local# # when machine startup, blow scripts will run.## This script is executed at the end of each multiuser runlevel.# Make sure that the script will "exit 0" on success or any other# value on error.## In order to enable or disable this script just change the execution# bits.## By default this script does nothing.export HISTTIMEFORMAT="%Y-%m-%d %H:%i:%S `whoami` " exit 0~
View Code

5.5 开启crontab日志

将cron.*前面的注释符去掉 1. 修改rsyslog(大致是第10行):sudo vim /etc/rsyslog.d/50-default.conf#cron.*    /var/log/cron.log 2. 重启rsyslog:sudo  service rsyslog  restart3. 查看crontab日志:tail -f /var/log/cron.log | nl

 

转载于:https://www.cnblogs.com/gophper/p/4852026.html

你可能感兴趣的文章
Java中日期的转化
查看>>
小程序弱网环境卡顿怎么办?一招迅速提升小程序运行速度
查看>>
管线【十八】
查看>>
重温设计模式 - 建造者模式
查看>>
Android开发 LevelListDrawable详解
查看>>
数组与字符串相互转换的方法总结
查看>>
Firefly安装说明 与 常见问题
查看>>
WP8:在Unity中使用OpenXLive
查看>>
Unity3d 接入 移动MM支付SDK(2.3) 全攻略
查看>>
ubuntu搭建svn服务器并htpp访问版本库并svn与web同步
查看>>
老系统如何引入更新的编码规范
查看>>
开发的模式总结
查看>>
Redis对象的数据结构基础理解
查看>>
SpringBoot非官方教程 | 第十八篇: 定时任务(Scheduling Tasks)
查看>>
Node.js在跑Express的时候有个时候会卡住按一下Ctrl+C又好了的解决办法
查看>>
Windows平台上使用ANT编译Hadoop Eclipse Plugin
查看>>
学习:MQTT协议及原理
查看>>
PAT乙级.1006.换个格式输出整数
查看>>
本地aar文件引用
查看>>
SimpleChannelInboundHandler与ChannelInboundHandlerAdapter
查看>>