cygwin安装cron服务

cygwin安装cron服务

cygwin 默认情况下未安装cron服务,

1、下载cron包

打开 cgwin的setup.exe,在select packages 中输入 cron 搜索

package选择:cron:Vixie’s cron

2、设置当前用户密码

默认情况下,登录cygwin的用户没有密码,会导致安装cron服务失败,错误提示:

Do you want to start the cron daemon as a service now? (yes/no) yes
cygrunsrv: Error starting a service: StartService:  Win32 error 1069:

所以,需要设置当前用户密码:

$ passwd
New password:
Re-enter new password:
Password changed.

2、安装cron服务

$ cron-config
The cron daemon can run as a service or as a job. The latter is not recommended.
Cron is already installed as a service under account .\hury.
Do you want to remove or reinstall it? (yes/no) yes
OK. The cron service was removed.

Do you want to install the cron daemon as a service? (yes/no) yes
Enter the value of CYGWIN for the daemon: [ ] cron

You must decide under what account the cron daemon will run.
If you are the only user on this machine, the daemon can run as yourself.
   This gives access to all network drives but only allows you as user.
To run multiple users, cron must change user context without knowing
  the passwords. There are three methods to do that, as explained in
  http://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-nopasswd1
If all the cron users have executed "passwd -R" (see man passwd),
  which provides access to network drives, or if you are using the
  cyglsa package, then cron should run under the local system account.
Otherwise you need to have or to create a privileged account.
  This script will help you do so.
Do you want the cron daemon to run as yourself? (yes/no) yes

Please enter the password for user 'hury':
Reenter:
Running cron_diagnose ...
WARNING: You do not currently have a crontab file.

... no problem found.

Do you want to start the cron daemon as a service now? (yes/no) yes
OK. The cron daemon is now running.

$ ps -l
      PID    PPID    PGID     WINPID   TTY         UID    STIME COMMAND
     3180   16876    3180      11600  ?         197609 08:31:02 /usr/sbin/cron

cron命令

crontab -e #编辑任务
crontab -l #查看任务列表
crontab -r #删除任务
cronevents #查看执行情况

新增cron任务

# 新增测试脚本
$ echo "echo "@`date +'%Y-%m-%d %H:%M:%S'`" hello, crontab is running">crontabTest.sh
$ crontab -e
* * * * * /home/hury/crontabTest.sh>/home/hury/crontabTest.log

查看cron任务

$ crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.RGxr32kWAC installed on Fri May 18 08:55:02 2018)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
* * * * * /home/hury/crontabTest.sh>/home/hury/crontabTest.log
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值