Вторник, 30.04.2024, 03:08
| RSS
Главная | Что такое Cron? - Sat-Net Forum
Sat-Net company
Форма входа
[Новые сообщения · Участники · Правила форума · Поиск · RSS ]
  • Страница 1 из 1
  • 1
Sat-Net Forum » Cyber Zone » Unix-like Systems » Что такое Cron?
Что такое Cron?
NuKe$Дата: Понедельник, 18.06.2007, 01:38 | Сообщение # 1
Admin
Группа: Администраторы
Сообщений: 63
Репутация: 0
Данная заметка предназначена для тех, кто собирается работать с cron, но еще не знает как все это делается. Я в кратции попробую объяснить что такое cron, для чего он нужен да и как вообще с ним работать. Надеюсь, что приведенная тут информация будет интересна и может быть даже полезна.

Итак что такое cron... cron-это программа которая позволяет вам в определенные вами моменты времени производить те или иные действия. Например запускать на выполнение какую либо программу или скрипт, обновлять данные и многое другое. Кстати, сразу же замечу, что cron это кусок от unix , так что не ищите его на Windows :) Там для этой цели используется совершенно другая вещь.

Очень часто cron используется для ротации логов, обновления сайтов выполнения каких-нить ежеминутных проверок или прочего. Так например я его использую в качестве помощника по архивации своего сайта. Написанный скрипт по архивации всех данных запускается по крону каждую неделю, в следствии чего я избавлен от головной боли 'а не забыл ли я чего архивнуть...'.

Да ну ладно, я думаю вы и так знаете (или уже догадались) для чего нужен крон. Так что посмотрим, как все это работает.

Для начала можно проверить, а запущен ли вообще этот самый крон ?

Команда ps ax |grep cron должна вывести вам то-то похожее на

407 ? S 0:00 crond
744 pts/0 S 0:00 grep cron

Т.е. если вы видите crond - то все в порядке, крон на месте.

Иначе вам просто 'повезло', либо на вашей машине не установлен крон, либо функции крона выполняет какой-то другой софт. Хотя такие ситуации необычайно редки.

Так что будем считать что все в порядке, и двинемся далее.
pages::
Как правило все ваши данные (задания) для крона хранятся по адресу /var/spool/cron/ в файле с именем соответствующим вашему логину. Например /var/spool/cron/nukes

Внутри файл выглядит следующим образом:
SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=vadim HOME=/home/vadim # run-parts 01 * * * * command 02 4 * * * command
Первые четыре строки просто обозначают настройку параметров окружения и на них не стоит обращать внимание (как в прочем и менять тоже), так как это задается уже самой системой.

А вот на следующие строки внимание уже стоит обратить...

Формат этих строк выглядит следующим образом:

Нужная минута часа для запуска (0-59)
Нужный час дня для запуска (0-23)
Нужный день месяца (0-30)
Нужный месяц года (1-12)
Нужный день недели (0-6)
Выполнимая команда.

Значок * обозначает слово каждый (день, год, месяц, час).

Итак например строка 01 * * * * command будет обозначать запуск программы каждый час в одну минуту.

А строка 02 4 * * * command означает запуск программы каждый день в 4 часа утра в две минуты.

В качестве уже более полного примера могу привести следующее:
01 * * * * echo `date` 'Hi man' >>$HOME/cron.res

Данное задание каждый час будет добавлять в файл cron.res текст Hi man и текущую дату.

Итак мы уже знаем как и по какому принципу работает крон, и поэтому мы сейчас перейдем к заключительному этому - его редактированию.

Редактирование крона происходит при помощи команды crontab.

crontab -e : войти в режим редактирования
crontab -l : вывести все задания крона
crontab -r : удалить все задания

Со второй и третьей командой обычно все ясно.

С первой командой просто хочу заметить, что редактирование будет простым открытием файла с заданиями через текстовый редактор. Как правило по умолчанию этим редактором является vi.

Но я так и не научился пользоваться этим редактором, поэтому использую pico.

Смену редактора можно провести командой
export EDITOR='pico' а далее и запускать команду редактирования.

Вот вроде бы и все. Удачного вам крона :)

 
vitya844Дата: Среда, 07.05.2008, 23:17 | Сообщение # 2
Новичок
Группа: Проверенные
Сообщений: 1
Репутация: 0
Замечания: 0%
Holidays in Great Britain

There are fewer public holidays in Great Britain than in other European countries. They are: Christmas Day, Boxing Day, New Year’s Day, Good Friday, Easter Monday, Mother’s Day, May Day, Spring Bank Holiday and Summer Bank Holiday. Public holidays in Britain are called bank holidays (on a day other than Saturday or Sunday) when all banks and post offices are closed, as well as most factories and offices and some shops.
The most popular holiday is Christmas. Christmas is the Christian celebration of the birth of Jesus Christ which takes place on 25 December. Before Christmas people send Christmas cards to their friends and family showing traditional Christmas symbols such as Santa Claus, angels, holly and snowmen. Shops are decorated for Christmas from September and in the weeks before Christmas people do their Christmas shopping, buying Christmas presents for friends and family. A few days before Christmas, families decorate a Christmas tree, a fir tree covered in lights and colourful decorations, in their home. Many people go to midnight mass in church on Christmas Eve. Young children believe that Santa Claus will bring them presents during the night and they usually wake up to find a stocking, a long sock filled with small presents, by their bed. Presents wrapped in coloured paper are put under the Christmas tree and on Christmas morning many families open their presents together. Families try to get together at Christmas and celebrate with special food. In Britain people eat mince pies and Christmas cake. They share a special meal, Christmas dinner, which in Britain usually consists of roast turkey and vegetables, followed by Christmas pudding.
Boxing Day is on 26 December, the day after Christmas Day. It is a bank holiday. Traditionally it was the day when people gave Christmas boxes (small gifts of money) to their employees or servants. Now most people relax, digest the food and drink of the day before, and perhaps visit friends or relatives.
New Year’s Day is less popular in Britain than Christmas. In Britain many people have parties on New Year’s Eve (- 31 December). At midnight it is traditional for people to sing Auld Lang Syne, to wish each other ‘Happy New Year’, and often to kiss each other. In large cities many people gather in public places on New Year’s Eve, such as Trafalgar Square in London or George Square in Glasgow. In Scotland the celebration of the New Year is called Hogmanay. New Year’s Day (- 1 January) is a bank holiday in Britain.

Mother’s Day is on the fourth Sunday in Lent (around the middle of March), when mothers traditionally receive gifts and cards from their children. It was originally a day when servants were given a holiday to visit their families, taking gifts of flowers or a cake.
Easter is a holiday in late March or early April, the first Sunday after the first full moon after 21 March. Many people spend it with their family or have a short holiday. It is also an important Christian festival. Easter Sunday, the day of the Resurrection, is the end of Lent and the most important date in the Christian year. Many people who do not go to church at other times go on Easter Sunday. It was once common for people to wear new clothes to church on this day. A few people send Easter cards with religious symbols on them or pictures of small chickens, lambs, rabbits and spring flowers, all traditionally associated with Easter.
The Friday before Easter Sunday is called Good Friday and is remembered as the day Christ was crucified. On Good Friday many people eat hot cross buns - fruit buns decorated with a simple cross.
Children look forward to Easter Sunday because they are given chocolate Easter eggs. These are also popular with adults and millions are sold in the weeks before Easter. Many are packed in coloured foil in brightly-coloured boxes decorated with pictures of cartoon characters. Others are decorated with sugar flowers and wrapped in clear paper tied with a ribbon. Some shops write the person’s name on the egg with icing. Inside each egg are sweets or chocolates. Smaller eggs with a sweet cream inside are also popular. Eggs represent new life and the start of spring, and children sometimes colour the shells of real eggs at home. In some parts of Britain Easter is a time for traditional events such as egg-rolling.
Easter Monday is the day after Easter Day. It is a traditional day to start of the summer tourist season. In Britain, Good Friday and Easter Monday are both bank holidays.
May Day is the first day of May, which has been marked in Britain for many centuries by outdoor events held to celebrate the arrival of spring. In Britain, traditional events on or near May Day include dancing round the maypole and choosing a May Queen. May Day itself is not necessarily a holiday in Britain, but since 1978 there has been a bank holiday on the Monday closest to 1 May, called the Early May Bank Holiday.
Spring Bank Holiday is the bank holiday that takes place each year on the last Monday in May in England, Northern Ireland and Wales.
Summer Bank Holiday is a bank holiday on the last Monday in August, when many people go to the coast, or to events such as the Edinburgh Festival or the Notting Hill Carnival. On Bank Holidays the townsfolk usually goes to the country or to the coast of the sea. If the weather is fine many families take a picnic lunch or tea with them and enjoy their meal in the open air. During these holidays there are also large fairs with swings and roundabouts.
Remembrance Sunday is the nearest Sunday to 11 November, on which ceremonies are held in Britain to remember the people killed during the two world wars and other conflicts. The largest ceremony is held in London, when politicians, Commonwealth figures and members of the royal family lay flowers at the Cenotaph in Whitehall. People used to stop what they were doing at 11 a.m. on Remembrance Day and stand in silence for two minutes to remember the dead. They traditionally wear a paper or plastic poppy on Remembrance Sunday and the days leading up to it, and the day is also called Poppy Day.
Besides public holidays there are some special festivals in Great Britain. One of them is called Bonfire Night. British people celebrate Bonfire Night every year on 5 November in memory of a famous event in British history, the Gunpowder Plot. On 5 November 1605 a group of Roman Catholics planned to blow up the Houses of Parliament while King James I was inside. On the evening before, one of them, Guy Fawkes was caught in the cellars with gunpowder, and the plot was discovered. He and all the other conspirators were put to death. Bonfire Night is sometimes called Guy Fawkes Night.
Originally, Bonfire Night was celebrated as a victory for Protestants over Catholics, but the festival is now enjoyed by everyone. Some children make a guy, a figure of a man made of old clothes stuffed with newspaper or straw to represent Guy Fawkes. The guy is then burned on top of a bonfire on Bonfire Night. A few days before, children take their guy into the street and ask for a ‘penny for the guy’, money for fireworks. Only adults are legally allowed to buy fireworks.
Some people hold private bonfire parties in their gardens, while others attend larger public events organized by local councils or charities. Chestnuts or potatoes are often put in the bonfire so that they will cook as it burns. Fireworks such as Roman Candles, Catherine Wheels, bangers and rockets are put in the ground and are let off one by one. Children hold lighted sparklers in their hands and wave them around.
Halloween is the night of 31 October, when people once believed that ghosts could be seen. Now, in Britain, it is a time when children have parties, dress up as witches, make lanterns out of pumpkins from which the inside has been removed, and play trick or treat.
St Valentine’s Day is on 14 February, the day on which lovers traditionally send one another greetings cards called Valentine cards or Valentines. The cards usually have designs of hearts, etc. on them and often include a sentimental or funny message. People sending Valentine cards do not usually sign their name. Sometimes people have a similar short message printed in a newspaper or magazine, and may also give each other gifts such as flowers or chocolates. The people who send or receive gifts, etc. in this way are also known as Valentines.
Pancake Day is another name for Shrove Tuesday, when many people eat pancakes in Britain. Traditionally, this was the last day when people could enjoy rich food before Lent.
There are also smaller, local festivals in Britain.

 
Sat-Net Forum » Cyber Zone » Unix-like Systems » Что такое Cron?
  • Страница 1 из 1
  • 1
Поиск:


Sat-Net company © 2007