In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
There are three conditions for executing a shell script using crontab:
1, must have permission
2, absolute path must be written
3, environmental variables
The format is
* / bin/sh / home/test.sh
The first *: 0: 59 minutes
The second *: 023 hours
Third *: date 1: 31
The fourth *: from January to December
The fifth *: Monday to 7
The first two conditions of crontab are relatively simple, so there is no explanation here. Here is mainly the problem of the third conditional environment variable. The reason why most crontab cannot run the script is this environment variable (to ensure the correctness of the script). This rookie also encountered the same problem today. Baidu Google has been looking for the reason for N long time, and finally confirmed that it is the problem of environment variable. Below, there is a second problem. How to set environment variables, continue Baidu, Google did not find the relevant configuration instructions, entangled with ing. This problem is really difficult for beginners.
The way to add environment variables after constant attempts is:
① executes echo $PATH on your server as follows:
/ usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
② under! / bin/bash of your script, add the following two lines:
PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Export PATH
Save exit
Rewrite crontab-e
* / bin/sh / home/test.sh
Success!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.