码迷,mamicode.com
首页 > 系统相关 > 详细

linux常用命令(配置查看,定时任务)

时间:2015-10-02 11:22:55      阅读:391      评论:0      收藏:0      [点我收藏+]

标签:

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

fdisk -l

技术分享
# fdisk -l

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk 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 / Solaris

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk 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    : 0
vendor_id    : GenuineIntel
cpu family    : 6
model        : 60
model name    : Intel(R) Core(TM) i5-4670 CPU @ 3.40GHz
stepping    : 3
microcode    : 0x19
cpu MHz        : 3443.429
cache size    : 6144 KB
physical id    : 0
siblings    : 4
core id        : 0
cpu cores    : 4
apicid        : 0
initial apicid    : 0
fdiv_bug    : no
f00f_bug    : no
coma_bug    : no
fpu        : yes
fpu_exception    : yes
cpuid level    : 13
wp        : yes
flags        : 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 rtm
bogomips    : 6796.22
clflush size    : 64
cache_alignment    : 64
address sizes    : 39 bits physical, 48 bits virtual
power management:

processor    : 1
vendor_id    : GenuineIntel
cpu family    : 6
model        : 60
model name    : Intel(R) Core(TM) i5-4670 CPU @ 3.40GHz
stepping    : 3
microcode    : 0x19
cpu MHz        : 3399.601
cache size    : 6144 KB
physical id    : 0
siblings    : 4
core id        : 1
cpu cores    : 4
apicid        : 2
initial apicid    : 2
fdiv_bug    : no
f00f_bug    : no
coma_bug    : no
fpu        : yes
fpu_exception    : yes
cpuid level    : 13
wp        : yes
flags        : 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 rtm
bogomips    : 6796.22
clflush size    : 64
cache_alignment    : 64
address sizes    : 39 bits physical, 48 bits virtual
power management:

processor    : 2
vendor_id    : GenuineIntel
cpu family    : 6
model        : 60
model name    : Intel(R) Core(TM) i5-4670 CPU @ 3.40GHz
stepping    : 3
microcode    : 0x19
cpu MHz        : 3400.000
cache size    : 6144 KB
physical id    : 0
siblings    : 4
core id        : 2
cpu cores    : 4
apicid        : 4
initial apicid    : 4
fdiv_bug    : no
f00f_bug    : no
coma_bug    : no
fpu        : yes
fpu_exception    : yes
cpuid level    : 13
wp        : yes
flags        : 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 rtm
bogomips    : 6796.22
clflush size    : 64
cache_alignment    : 64
address sizes    : 39 bits physical, 48 bits virtual
power management:

processor    : 3
vendor_id    : GenuineIntel
cpu family    : 6
model        : 60
model name    : Intel(R) Core(TM) i5-4670 CPU @ 3.40GHz
stepping    : 3
microcode    : 0x19
cpu MHz        : 3400.000
cache size    : 6144 KB
physical id    : 0
siblings    : 4
core id        : 3
cpu cores    : 4
apicid        : 6
initial apicid    : 6
fdiv_bug    : no
f00f_bug    : no
coma_bug    : no
fpu        : yes
fpu_exception    : yes
cpuid level    : 13
wp        : yes
flags        : 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 rtm
bogomips    : 6796.22
clflush size    : 64
cache_alignment    : 64
address sizes    : 39 bits physical, 48 bits virtual
power management:
View Code

 

 

3.查看内存信息

cat /proc/meminfo

技术分享
cat /proc/meminfo
MemTotal:        4090736 kB
MemFree:         1628156 kB
MemAvailable:    2270864 kB
Buffers:            7984 kB
Cached:           991184 kB
SwapCached:            0 kB
Active:          1458132 kB
Inactive:         838020 kB
Active(anon):    1102336 kB
Inactive(anon):   377500 kB
Active(file):     355796 kB
Inactive(file):   460520 kB
Unevictable:          32 kB
Mlocked:              32 kB
HighTotal:       3227012 kB
HighFree:        1084212 kB
LowTotal:         863724 kB
LowFree:          543944 kB
SwapTotal:       4133884 kB
SwapFree:        4133884 kB
Dirty:               308 kB
Writeback:             0 kB
AnonPages:       1297060 kB
Mapped:           605736 kB
Shmem:            182856 kB
Slab:              53976 kB
SReclaimable:      30016 kB
SUnreclaim:        23960 kB
KernelStack:        4592 kB
PageTables:        16260 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     6179252 kB
Committed_AS:    6168352 kB
VmallocTotal:     122880 kB
VmallocUsed:       52824 kB
VmallocChunk:      61204 kB
AnonHugePages:    520192 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:      378872 kB
DirectMap2M:      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 crons system
# daemons 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 crons system
# daemons 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.txt
2015年 10月 02日 星期五 10:24:01 CST
2015年 10月 02日 星期五 10:26:01 CST
2015年 10月 02日 星期五 10:28:01 CST
2015年 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

 

linux常用命令(配置查看,定时任务)

标签:

原文地址:http://www.cnblogs.com/gophper/p/4852026.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!