Home > System Tutorial > LINUX > Detailed method to solve invalid crontab problem in ubuntu

Detailed method to solve invalid crontab problem in ubuntu

WBOY
Release: 2024-01-01 19:11:54
forward
1475 people have browsed it

Enable crontab in Debain's docker. I have been dealing with the problem for a day, so I will record it here. Debain is similar to ubuntu, so it is included under ubuntu.

1. The first question, install crontab

apt-get install cron
Copy after login

Look clearly, it’s cron, not crond! There is no need for things like vixie-cron required for installation under centos! The various tutorials applicable to centos on the Internet really confused me! Remember, only the above command is enough under ubuntu!

2. Start the crontab service

/etc/init.d/cron status  #查看状态

/etc/init.d/cron restart  #启动服务
Copy after login

You can also use ps -ef|grep cron to check the status, or use service start cron to start the service. Just remember one thing, it is cron, not crond! Crond is used by centos.

3. For docker, if you are not using docker, you can skip this step

Modify the /etc/pam.d/cron file, change required to sufficient, and then restart the cron service: /etc/init.d/cron restart

4. The absolute path must be used in the script

Whether it is a shell script or a python script, all paths in it must be absolute paths!

5. Import the required environment variables

example

0 8 * * * . /etc/profile; /bin/sh /home/abc/test.sh

0 8 * * * /bin/usr/python2.7 /home/abc/test.py
Copy after login

If these are all ok, there should be no problem.

The above is the detailed content of Detailed method to solve invalid crontab problem in ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jb51.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template