Я тестирую crobtab с простым сценарием, который работает в течение каждой минуты (вставил temp.sh ниже), Но он не работает
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
* * * * * /home/temp/temp.sh
temp.sh
backup_dir=`date "+%Y-%m-%d-%H-%M-%S"`
echo $backup_dir >> $PWD/temp.txt
Детали разрешения:
-rwxrwxrwx 1 temp temp 73 Mar 14 21:55 temp.sh
-rw-rw-r-- 1 temp temp 100 Mar 14 21:59 temp.txt
ПРИМЕЧАНИЕ: когда я работаю вручную как "/home/temp/temp.sh", Он работает и печатает дату в файле temp.txt
Anyhelp ценится.Спасибо
LINUX: Ubuntu 18
crontab -e
файл должен быть:
*/1 * * * */home/temp/temp.sh
Удостоверьтесь, что temp.sh имеет, выполняют разрешение создать использование temp.txt chmod +x temp.sh
.
Также добавьте хижину и CD к выходному каталогу в temp.sh файле
#!/bin/sh
backup_dir=`date "+%Y-%m-%d-%H-%M-%S"`
cd /home/temp/
echo $backup_dir >> $PWD/temp.txt
Вы проверили ли /etc/cron.allow
существует? В этом случае пользователь "временный файл" должен быть перечислен там. Кроме этого, /var/log/syslog
должен содержать любую связанную ошибку/сообщения о состоянии.