㈠ suse linux
Newbie: Intro to cron
Date: 30-Dec-99
Author: cogNiTioN <[email protected]>
Cron
This file is an introction to cron, it covers the basics of what cron does,
and how to use it.
What is cron?
Cron is the name of program that enables unix users to execute commands or
scripts (groups of commands) automatically at a specified time/date. It is
normally used for sys admin commands, like makewhatis, which builds a
search database for the man -k command, or for running a backup script,
but can be used for anything. A common use for it today is connecting to
the internet and downloading your email.
This file will look at Vixie Cron, a version of cron authored by Paul Vixie.
How to start Cron
Cron is a daemon, which means that it only needs to be started once, and will
lay dormant until it is required. A Web server is a daemon, it stays dormant
until it gets asked for a web page. The cron daemon, or crond, stays dormant
until a time specified in one of the config files, or crontabs.
On most Linux distributions crond is automatically installed and entered into
the start up scripts. To find out if it's running do the following:
cog@pingu $ ps aux | grep crond
root 311 0.0 0.7 1284 112 ? S Dec24 0:00 crond
cog 8606 4.0 2.6 1148 388 tty2 S 12:47 0:00 grep crond
The top line shows that crond is running, the bottom line is the search
we just run.
If it's not running then either you killed it since the last time you rebooted,
or it wasn't started.
To start it, just add the line crond to one of your start up scripts. The
process automatically goes into the back ground, so you don't have to force
it with &. Cron will be started next time you reboot. To run it without
rebooting, just type crond as root:
root@pingu # crond
With lots of daemons, (e.g. httpd and syslogd) they need to be restarted
after the config files have been changed so that the program has a chance
to reload them. Vixie Cron will automatically reload the files after they
have been edited with the crontab command. Some cron versions reload the
files every minute, and some require restarting, but Vixie Cron just loads
the files if they have changed.
Using cron
There are a few different ways to use cron (surprise, surprise).
In the /etc directory you will probably find some sub directories called
'cron.hourly', 'cron.daily', 'cron.weekly' and 'cron.monthly'. If you place
a script into one of those directories it will be run either hourly, daily,
weekly or monthly, depending on the name of the directory.
If you want more flexibility than this, you can edit a crontab (the name
for cron's config files). The main config file is normally /etc/crontab.
On a default RedHat install, the crontab will look something like this:
root@pingu # cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
The first part is almost self explanatory; it sets the variables for cron.
SHELL is the 'shell' cron runs under. If unspecified, it will default to
the entry in the /etc/passwd file.
PATH contains the directories which will be in the search path for cron
e.g if you've got a program 'foo' in the directory /usr/cog/bin, it might
be worth adding /usr/cog/bin to the path, as it will stop you having to use
the full path to 'foo' every time you want to call it.
MAILTO is who gets mailed the output of each command. If a command cron is
running has output (e.g. status reports, or errors), cron will email the output
to whoever is specified in this variable. If no one if specified, then the
output will be mailed to the owner of the process that proced the output.
HOME is the home directory that is used for cron. If unspecified, it will
default to the entry in the /etc/passwd file.
Now for the more complicated second part of a crontab file.
An entry in cron is made up of a series of fields, much like the /etc/passwd
file is, but in the crontab they are separated by a space. There are normally
seven fields in one entry. The fields are:
minute hour dom month dow user cmd
minute This controls what minute of the hour the command will run on,
and is between '0' and '59'
hour This controls what hour the command will run on, and is specified in
the 24 hour clock, values must be between 0 and 23 (0 is midnight)
dom This is the Day of Month, that you want the command run on, e.g. to
run a command on the 19th of each month, the dom would be 19.
month This is the month a specified command will run on, it may be specified
numerically (0-12), or as the name of the month (e.g. May)
dow This is the Day of Week that you want a command to be run on, it can
also be numeric (0-7) or as the name of the day (e.g. sun).
user This is the user who runs the command.
cmd This is the command that you want run. This field may contain
multiple words or spaces.
If you don't wish to specify a value for a field, just place a * in the
field.
e.g.
01 * * * * root echo "This command is run at one min past every hour"
17 8 * * * root echo "This command is run daily at 8:17 am"
17 20 * * * root echo "This command is run daily at 8:17 pm"
00 4 * * 0 root echo "This command is run at 4 am every Sunday"
* 4 * * Sun root echo "So is this"
42 4 1 * * root echo "This command is run 4:42 am every 1st of the month"
01 * 19 07 * root echo "This command is run hourly on the 19th of July"
Notes:
Under dow 0 and 7 are both Sunday.
If both the dom and dow are specified, the command will be executed when
either of the events happen.
e.g.
* 12 16 * Mon root cmd
Will run cmd at midday every Monday and every 16th, and will proce the
same result as both of these entries put together would:
* 12 16 * * root cmd
* 12 * * Mon root cmd
Vixie Cron also accepts lists in the fields. Lists can be in the form, 1,2,3
(meaning 1 and 2 and 3) or 1-3 (also meaning 1 and 2 and 3).
e.g.
59 11 * * 1,2,3,4,5 root backup.sh
Will run backup.sh at 11:59 Monday, Tuesday, Wednesday, Thursday and Friday,
as will:
59 11 * * 1-5 root backup.sh
Cron also supports 'step' values.
A value of */2 in the dom field would mean the command runs every two days
and likewise, */5 in the hours field would mean the command runs every
5 hours.
e.g.
* 12 10-16/2 * * root backup.sh
is the same as:
* 12 10,12,14,16 * * root backup.sh
*/15 9-17 * * * root connection.test
Will run connection.test every 15 mins between the hours or 9am and 5pm
Lists can also be combined with each other, or with steps:
* 12 1-15,17,20-25 * * root cmd
Will run cmd every midday between the 1st and the 15th as well as the 20th
and 25th (inclusive) and also on the 17th of every month.
* 12 10-16/2 * * root backup.sh
is the same as:
* 12 10,12,14,16 * * root backup.sh
When using the names of weekdays or months, it isn't case sensitive, but only
the first three letters should be used, e.g. Mon, sun or Mar, jul.
Comments are allowed in crontabs, but they must be preceded with a '#', and
must be on a line by them self.
Multiuser cron
As Unix is a multiuser OS, some of the apps have to be able to support
multiple users, cron is one of these. Each user can have their own crontab
file, which can be created/edited/removed by the command crontab. This
command creates an indivial crontab file and although this is a text file,
as the /etc/crontab is, it shouldn't be edited directly. The crontab file is
often stored in /var/spool/cron/crontabs/<user> (Unix/Slackware/*BSD),
/var/spool/cron/<user> (RedHat) or /var/cron/tabs/<user> (SuSE),
but might be kept elsewhere depending on what Un*x flavor you're running.
To edit (or create) your crontab file, use the command crontab -e, and this
will load up the editor specified in the environment variables EDITOR or
VISUAL, to change the editor invoked on Bourne-compliant shells, try:
cog@pingu $ export EDITOR=vi
On C shells:
cog@pingu $ setenv EDITOR vi
You can of course substitute vi for the text editor of your choice.
Your own personal crontab follows exactly the same format as the main
/etc/crontab file does, except that you need not specify the MAILTO
variable, as this entry defaults to the process owner, so you would be mailed
the output anyway, but if you so wish, this variable can be specified.
You also need not have the user field in the crontab entries. e.g.
min hr dom month dow cmd
Once you have written your crontab file, and exited the editor, then it will
check the syntax of the file, and give you a chance to fix any errors.
If you want to write your crontab without using the crontab command, you can
write it in a normal text file, using your editor of choice, and then use the
crontab command to replace your current crontab with the file you just wrote.
e.g. if you wrote a crontab called cogs.cron.file, you would use the cmd
cog@pingu $ crontab cogs.cron.file
to replace your existing crontab with the one in cogs.cron.file.
You can use
cog@pingu $ crontab -l
to list your current crontab, and
cog@pingu $ crontab -r
will remove (i.e. delete) your current crontab.
Privileged users can also change other user's crontab with:
root@pingu # crontab -u
and then following it with either the name of a file to replace the
existing user's crontab, or one of the -e, -l or -r options.
According to the documentation the crontab command can be confused by the
su command, so if you running a su'ed shell, then it is recommended you
use the -u option anyway.
Controlling Access to cron
Cron has a built in feature of allowing you to specify who may, and who
may not use it. It does this by the use of /etc/cron.allow and /etc/cron.deny
files. These files work the same way as the allow/deny files for other
daemons do. To stop a user using cron, just put their name in cron.deny, to
allow a user put their name in the cron.allow. If you wanted to prevent all
users from using cron, you could add the line ALL to the cron.deny file:
root@pingu # echo ALL >>/etc/cron.deny
If you want user cog to be able to use cron, you would add the line cog
to the cron.allow file:
root@pingu # echo cog >>/etc/cron.allow
If there is neither a cron.allow nor a cron.deny file, then the use of cron
is unrestricted (i.e. every user can use it). If you were to put the name of
some users into the cron.allow file, without creating a cron.deny file, it
would have the same effect as creating a cron.deny file with ALL in it.
This means that any subsequent users that require cron access should be
put in to the cron.allow file.
Output from cron
As I've said before, the output from cron gets mailed to the owner of the
process, or the person specified in the MAILTO variable, but what if you
don't want that? If you want to mail the output to someone else, you can
just pipe the output to the command mail.
e.g.
cmd | mail -s "Subject of mail" user
If you wish to mail the output to someone not located on the machine, in the
above example, substitute user for the email address of the person who
wishes to receive the output.
If you have a command that is run often, and you don't want to be emailed
the output every time, you can redirect the output to a log file (or
/dev/null, if you really don't want the output).
e,g
cmd >> log.file
Notice we're using two > signs so that the output appends the log file and
doesn't clobber previous output.
The above example only redirects the standard output, not the standard error,
if you want all output stored in the log file, this should do the trick:
cmd >> logfile 2>&1
You can then set up a cron job that mails you the contents of the file at
specified time intervals, using the cmd:
mail -s "logfile for cmd" <log.file
Now you should be able to use cron to automate things a bit more.
A future file going into more detail, explaining the differences between
the various different crons and with more worked examples, is planned.
Additional Reference:
Man pages: cron(8) crontab(5) crontab(1)
Book: _Running Linux_ (O'Reilly ISBN: 1-56592-469-X)
cog
© Copyright 2000 cogNiTioN <[email protected]>
㈡ suse 系统的评估代码怎么获得
SUSE Linux 原来是德国的 SuSE Linux AG公司发行维护的Linux发行版。
1、SUSE集成管理界面不仅仅是软件,SUSE可以使管理员不需要对组件进行深入研究而进行配置,SUSE可以配置管理需要或者不需要的所有组件。
2、在SUSE LinuxEnterprise Server里却不是这样。SUSE依赖于另一个安装工具,SUSE在系统的每一个版本更新中都有做改进,通过在SUSE的现状可以看出。
3、SUSE有一个综合管理程序控制面板,这很重要。管理员可以方便的通过SUSE的综合管理工具面板来获得新的软件。
4、SUSE的使用案例是与混合服务器操作系统的环境,那里的管理员管理系统只有一个肤浅的认识:UNIX和Linux编程。
5、SUSE Linux的YaST可以和命令行交叉工作,SUSE之间可以互补,所以习惯用SUSE编程命令行来管理服务器也可以达到相应的效果。
6、在SUSE早期版本,SUSE会损坏一些手动创建的配置。Linux的早起管理员都有过这种经历:SUSE损坏了管理大量手工创建的配置。然而,SUSE的配置改变现在已经有完善的告警机制,管理员们可以放心的使用SUSE。
7、在新近的SUSE版本里,SUSE会自动备份配置文件和显示手动修改过的配置,SUSE这样的机制可以保证最大化的配置丢失风险
㈢ suse linux这是什么系统(普通电脑可以装吗向华硕可以吗)
一楼真可笑。suse是一种linux系统,用rpm软件包。在大部分pc机上都能装,我的小Y第二系统就是opensuse12.1。suse是企业用的,需要付费,opensuse是免费的下载安装就好,官网有一些指南(
)。不过suse似乎构架跟别人不一样,像gtk的使用跟ubuntu就不一样。总的来说适合使用不适合玩系统,里面有个软件叫yast跟windows的控制面板差不多,windows用户比较容易上手。opensuse对硬件的要求稍高些,安装kde的suse被称为最漂亮的操作系统,但是建议使用gnome桌面,因为权限争执比较小
㈣ 请问SUSE Linux Enterprise Server 11激活代码去哪找
安装个桌面版本就好了
如果实在要服务器版本就安装CentOS吧
㈤ Suse Linux的Yast2相对于cmd命令有什么优势
YAST2是图形化界面,对于不熟悉命令的同学有很大的帮助
㈥ opensuse和suse的区别
SUSE linux原来是德国的一个linux发行版本,在欧洲很流行,有广阔的市场.2003年的时候被NOVELL收购,成为其旗下的一个产品.它开发的XGL是第一个真正意义上实现3D桌面效果的OS.suse linux在9.0的时候是要收钱的,后来受的压力太大了,从10.0才开始免费的.
NOVELL公司有两种linux版本,一个是OPEN SUEE,另一个是Enterprise linux,后一个是为企业而设计的,要长期使用,是要收一定的费用的.而前一个是完全按照开源社区的要求,是免费的和放开源代码的.
SUSE linux界面华丽,不过也很占资源,一般不建议配置比较低的用户的安装!运行SUSE 好像你的电脑运行VISTA一样!
suse linux10.0以后的版本都叫 openSUSE,目前Novell官方网站上公布的最高版本是Suse Linux Enterprise SP2 。
openSUSE 项目是由Novell公司资助的全球性社区计划,旨在推进 Linux 的广泛使用。这个计划提供免费的 openSUSE 操作系统。
openSUSE 是 Novell 公司发行的企业级 Linux 产品的系统基础。
openSUSE 项目的目标是:
使 SUSE Linux 成为所有人都能够得到的最易于使用的 Linux 发行版,同时努力使其成为使用最广泛的开放源代码平台。
为开放源代码合作者提供一个环境来把 SUSE Linux 建设成世界上最好的 Linux 发行版,不论是为新用户或者有经验的 Linux 用户。
大大简化并开放开发和打包流程,以使 openSUSE 成为 Linux 黑客和应用软件开发者的首选平台
捎带一讲:
openSUSE 项目和Fedora有什么区别?
Fedora 项目,被红帽公司支持,是一个强大的社区对开源的贡献。还有其它大型开源项目,比如Debian和Ubuntu,提供活跃的用户开发社区。总体来讲,这些开源项目桌面更注重以工程为中心的技术问题,把它们提供给 Linux 用户开发者的技术性社区。
openSUSE 项目不会区分技术性社区和由 Linux 用户组成的非技术性社区。openSUSE 项目通过公开透明的开发流程,创造一个稳定精良的 Linux 发行版( SUSE Linux ),提供 Linux 用户所需要的一切。( SUSE Linux 一直被评论为最设计最好而且最好用的 Linux 。)为实现把 Linux 带给每个人的目标,openSUSE 项目使潜在 Linux 用户能通过各种渠道更容易的获得 SUSE Linux ,包括带文档的用户端零售版。只有 openSUSE 项目为了让业余用户能够有最好的 Linux 体验而不断改善 Linux 发行版。
当具体的和Fedora相比,openSUSE 项目开发并包含了很多Fedora所没有的其它重要开放标准,比如CIM (the Common Information Model)和YaST (一个标准开源的 Linux 配置管理套件)。此外,openSUSE 项目在桌面和易用性方面努力良多,被许多全球顶尖的开源GUI设计者所强化
㈦ Suse12.3怎样挂载安装镜像文件
mkdir /mnt/cd2
mount -o loop /../LabVIEW fo Linux.iso /mnt/cd2
或用虚拟光驱软件。。。。
编辑grub.conf
root (hd0,6)#iso文件所在位置
kernel /vmlinuz boot=casper iso-scan/filename=/LabVIEW fo Linux.iso
initrd /initrd.gz
㈧ suse linux是啥系统和linux、unix 有什么区别,solaris有是啥东西啊,各位大侠帮忙解释一下!
solaris是SUN公司的unix操作系统
suse linux是linux操作系统的一个分支版本
linux和unix的区别是,先有unix,再有的linux,一般企业和个人用linux就可以了,unix对硬件有要求
㈨ suse linux 如何关闭selinux
SUSE Linux 默认不会开启 SELinux
YaST-->系统-->运行级别-->关闭SELinux 即可.
---
如果你用了内核参数的形式的,必须修改GRUB,在 引导代码后添加:
selinux=0
㈩ SUSE Linux乱码问题
解决方案无非就是把python的代码的开头编码用utf-8,打开数据库连接的时候也用charset='utf8',还搞什么sys.setdefaultencoding('gbk'),mysql的my.cnf配置文件里面配置为utf-8。等等之类的东西,无效,插入中文还是乱码,就是插到数据库里面,直接看数据库里的中文都是编码,或者是????什么的。
把问题简单化,mysql的默认编码为latin1,查找mysqldb的源码关键报错的地方是cursor.execute,这里要执行一下encode(charset),既然这里要encode,那就在外面先decode一下,果然什么都不改,在自己的调用函数里做decode。
sql
=
'insert
into
aa
values('测试')'
sql
=
sql.decode('latin1')
cursor.execute(sql)
这样就解决问题了,中文插入,中文显示,在终端命令行直接查看数据库也是中文。
试试,建表的时候不需要指定编码。