LinuxForum.Fans
Тема

Запуск скрипта периодически в centos

Автор: DarkDigger 5 сообщений 4941 просмотров
#272054

Есть необходимость запуска скрипта каждую минуту скажите как это сделать?

#272056
text
man cron

[console=root]crontabs -e[/console]

text
cat /var/spool/cron/crontabs/root 
# If you don't want the output of a cron job mailed to you, you have to direct
# any output to /dev/null.  We'll do this here since these jobs should run
# properly on a newly installed system, but if they don't the average newbie
# might get quite perplexed about getting strange mail every 5 minutes. :^)
#
# Run the hourly, daily, weekly, and monthly cron jobs.
# Jobs that need different timing may be entered into the crontab as before,
# but most really don't need greater granularity than this.  If the exact
# times of the hourly, daily, weekly, and monthly cron jobs do not suit your
# needs, feel free to adjust them.
#
# Run hourly cron jobs at 47 minutes after the hour:
47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null
#
# Run daily cron jobs at 4:40 every day:
40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null
#
# Run weekly cron jobs at 4:30 on the first day of the week:
30 4 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null
#
# Run monthly cron jobs at 4:20 on the first day of the month:
20 4 1 * * /usr/bin/run-parts /etc/cron.monthly 1> /dev/null
#272061

Спасибо, крон это то что нужно) Скажите вот я залогинился под root, ввёл всё что нужно в команде crontab -e. команды будут выполнятся от root? Когда я разлогинюсь, крон продолжит выполнять команды?

#272064

Да, от root, будут выполняться, для этого он и предназначен.
Если планируется выполнение от root, нужные команды можно добавить в общесистемный файл конфигурации — /etc/crontab.

Войдите или зарегистрируйтесь, чтобы ответить.