-1

I have following questions on cron.

  1. What is the preferred way for automating cron jobs? Using a) crontab command-line options (eg. crontab -e) or b) editing /etc/crontab. What is the difference between the two? It's not exactly clear to me.

  2. Is crontab user specific? If I am logged in as a a user say "anup", and add jobs using crontab -e, will the job be user-specific? However, in some of the cron examples I checked online, username is provided as a field between the time string and the command to be executed.

  3. Can the 'Mail to user" option be controlled for each job? As in, for job 1: MailTO: root for job 2: MailTO: anup.

4

1 回答 1

0
  1. crontab 实用程序是一个命令行工具,用于维护单个用户的 crontab 文件。

    crontab -l列出/查看当前用户的 crontab

    crontab -e编辑 crontab

    您可以键入man crontab以获取大多数 linux/mac 系统上的完整文档。

  2. crontab 是特定于用户的。如果您以 anup 身份登录,则 crontab -e 将编辑 anup 的 crontab 文件。您可以使用 -u 标志指定用户(crontab -u)

  3. 我不是 100% 确定,但我相信您可以指定一个新的 MAILTO= 设置,它将对之后执行的所有进程生效。

于 2012-08-20T18:51:32.980 回答