现在的位置: 首页 > 综合 > 正文

71、shell中crontab中执行命令的特殊性,/bin/sh

2011年09月13日 ⁄ 综合 ⁄ 共 424字 ⁄ 字号 评论关闭

1、在执行crontab命令时,与直接在shell中执行程序有点区别,要引起注意。如ps aux | grep file

直接在shell中执行,则搜索范围只在top中当前执行的进程,而写入crontab执行,则crontab中所有语句也成为了搜索范围。

count = `ps aux | grep file | wc -l`

2、写的脚本前面加/bin/sh

如果要用给脚本执行权限的话,第一行必须声明该脚本由什么来解释。比如:

#! /usr/local/php/bin/php

#! /bin/sh

效果如同:/bin/sh Scriptname

"#! /bin/sh"是对shell的声明,说明你所用的是那种类型的shell及其路径所在。可以理解为#!为特殊声明符。

参考

1http://linux.die.net/man/1/head

2】 关于/bin/sh

http://www.cnblogs.com/ghj1976/archive/2010/07/12/1775860.html

抱歉!评论已关闭.