CronJob not running

前端 未结 11 1260
攒了一身酷
攒了一身酷 2020-11-22 02:33

I have set up a cronjob for root user in ubuntu environment as follows by typing crontab -e

  34 11 * * * sh /srv/www/live/CronJobs/daily.sh
  0          


        
11条回答
  •  轮回少年
    2020-11-22 02:44

    I've found another reason for user's crontab not running: the hostname is not present on the hosts file:

    user@ubuntu:~$ cat /etc/hostname
    ubuntu
    

    Now the hosts file:

    user@ubuntu:~$ cat /etc/hosts
    127.0.0.1 localhost
    
    # The following lines are desirable for IPv6 capable hosts
    ::1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    

    This is on a Ubuntu 14.04.3 LTS, the way to fix it is adding the hostname to the hosts file so it resembles something like this:

    user@ubuntu:~$ cat /etc/hosts
    127.0.0.1 ubuntu localhost
    
    # The following lines are desirable for IPv6 capable hosts
    ::1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    

提交回复
热议问题