--cron --- Regularly executed daemon --crontab --- Schedule cron
Execution environment Linux Mint (19.1 Tessa), EC2 (Amazon Linux2)
You can display the current settings with the following command
$crontab -l
I ran the above command in docker and on a Mac, but the command didn't exist (* I checked it later and found it on the Mac ... the display was a little different, so it seems to be a mistake). For the time being, I tried it on a Linux Mint (19.1 Tessa) PC. If crontab can be used and it is not set, it will be displayed as follows. You will be able to edit the settings with the following command. At first, you will be asked to specify an editor. (I set it to Vim this time. Nano was recommended)
$crontab -e
Commands are minutes, hours, days, months, days of the week, commands Describe in the order of, and leave a half-width space. The following is the setting to run the shell every 10 minutes
*/10 * * * * /home/user/test.sh
Command to check cron execution log
--For Linux Mint
grep CRON /var/log/syslog
--For EC2
sudo grep CRON /var/log/cron
Nothing happened even if I set it, so when I checked the execution log, the following display was displayed. After investigating, it is said that Ubuntu and Ubuntu are events that occur in the base Linux Mint.
Installing postfix fixed the above error.
sudo aptitude install postfix
I solved the problem (1), but the shell didn't work at all.
When I checked the file permissions with the ls -l
command, it was `` `-rw-rw-r --```.
Granted execute permission. (Since the authority is given to move it for the time being, please change it if necessary)
chmod +x test.sh
The shell worked fine.
By the way, I just wanted to check the operation of cron, so I used a simple command as follows.
echo "test cron1" >> /home/owner/aaa.txt
Recommended Posts