Avatar billede nuck Nybegynder
21. februar 2002 - 16:52 Der er 8 kommentarer

CronTab? (Cron Job)

Hey!
Jeg vil gerne oprette en cron job som kører en php fil..

Hvad skal jeg så angive som kommando ?
Avatar billede nuck Nybegynder
21. februar 2002 - 16:55 #1
Jeg skal angive 2 ting faktisk :
Command 
Input to command
Avatar billede nuck Nybegynder
21. februar 2002 - 16:56 #2
Kan godt smide 100 point mere hvis det ikke er nok det her ?
Avatar billede cybermike Nybegynder
21. februar 2002 - 19:37 #3
først, "crontab -e"

derefter....tjaaee, hvilken dist kører du , hvor ligger programmet og hvor tit skal det køres?
Avatar billede billen Nybegynder
21. februar 2002 - 19:58 #4
Husk at dit php script skal have #!/path/to/php-bin i toppen!
Avatar billede siemen Nybegynder
21. februar 2002 - 20:38 #5
Fant en del om crontab i en gammel unix-manual.  Er det noe nyttig her:

crontab

schedule commands to be executed at regular intervals

Syntax

crontab [file I

crontab -r

crontab -1

crontab -u user -r

crontab -u user -1

  Desciiption

The crontab command can be used to schedule commands to be executed at
regular intervals.  These commands are stored in the user's crontab file,
lusrlspoollcronlcrontabslusemame.  Any output or errors generated by the com-
mands are mailed to the user.

If called with no options, crontab copies the specified file, or standard input if
no file is specified, into the crontabs directory (if the user has a previous
crontab file:it is replaced).

crontab with the -r option removes the user's crontab file from the crontabs
directory.

crontab with the -1 option lists the contents of the user's crontab file.

The -u option allows crontab to maniplulate a different crontab file fro
invoking users.  If crontab is used from an su session then crontab by defaul
will manipulate the styed users crontab file.  The -u option may be used t
direct crontab to manipulate the original login user's crontab file instead.  Th
super user (root) can also use the -u option to manipulate any users cront
file.
If the file lusrlliblcronlcron.allow exists, only the users listed in that file ar
allowed to use crontab.  If cron.allow does not exist, and the fil
lusrlliblcronlcron.deny does, then all users not listed in cron.deny are allowe
access to crontab, with an empty cron.deny allowing global usage.  If neith
file exists, only the super user is allowed to submit a job.  The allow /deny fil
consist of one user name per line.

  The crontabs files consist of lines of six fields each.  The fields are separated by
  spaces or tabs.  The first five are integer patterns that specify the minute
  (0-59), hour (0-23), day of the month (1-31), month of the year (1-12), and day
  of the week (0-6, with -O=Sunday).  Each of these patterns may contain:
  o a number in the (respective) range indicated above
  9 two numbers separated by a minus (indicating an inclusive range)
  o a list of numbers separated by commas (meaning all of these numbers)
  o an asterisk (meaning all legal values)

  Note that the specification of days may be made by two fields (day of the
  month and day of the week).  If 6oth are specified as a list of elements, both
  are adhered to.  For example, 0 0 1,15 * 1 would run a command on the first
  and fifteenth of each month, as well as on every Monday.  To specify days by
  only one field, the other field should be set to (for example, 0 0 1
  would run a command only on Mondays).

  The sixth field is a strinly that is executed by the shell at the specified time(S).
u
  A ' % " in this field is translated into a newline character.  Only the first line
  (up to a '%' or end-of-line) of the command field is executed by the shell.
  T'he other lines are made available to the command as standard input.

  T'he shell is invoked from your $HOME directory with an argo of sh.  Users
  who desire to have their Profile executed must explicitly do so in the crontab
  file. cron supplies a default environment for e@erv shell, defining HOME,
  LOGNAME, SHELL (=Ibinlsh), and PATH(=Ibinlusrlbi@.-).

Erit values

  crontab exits and returns a value of 55 if it cannot allocate enough memory.  If
  it exits for any other reason, it returns a value of 1.

  If the user (of -u user) does not exist, crontab returns a value of 1 and an error
  message.

mples

  An example crontabs file follows:
  0 4  *  *  * calendar -
  15  4  *  *  * find /usr/preserve -mtime +7 -exec rm -f fl
  30  4  1  *  I /usr/lib/uucp/uuclean
  40  4  *  *  * find / -name '#*' -atime +3 -exec rm -f i)
  1,21,41*  *  *  * (echo -n ' '; date; echo ) >/dev/console

I1. 'ie nes in s examp  o t  owing: run  ca  ar program every
night at 4:00 am, clear old files from the letclpreserve directory every night at
4:15 am, clean up the uucp spool directory every Monday and the first of
every month at 4:30 am, find and remove any old files with names beginning
with '#' every night at 4:40 am, and echo the current date and time to the
console three times an hour at one minute, 21 minutes, and 41 minutes past
the hour.

Limitations

crontab commands are executed by cron(C). cron reads the files in the cron-
tabs directory only on startup or when a new crontab is submitted with the
crontab command, so changes made to these files by hand will not take effect
until the system is rebooted.  Changes submitted with the crontab command
will take effect as soon as cron is free to read them (that is, when cron is not in
the process of running a scheduled job or reading another newly submitted
at(C) or crontab job).

Users who do not wish to have output from their commands mailed to them
may want to redirect it to a file:
  0 * * * * who >> /tmp/whofile 2> /dev/null
The example above would append the output of the who(C) command to a
file, and throw away any errors generated.  For more details on output
redirection, see the sh(C) manual page.

Users should remember to redirect the standard output and standard error of
their commands, otherwise any generated output or errors will be mailed to
the user.

crontab will overwrite any previous crontab submitted by the same user.

Care should be taken when scheduling commands to run during time zone
changes from the standard time to the daylight savings time.  This is because
when the clocks go forward, certain times cease to exist.  For example, when
the clocks go forward an hour at 2 am, all times between 2 am and 3 am
(including 2 am) cease to exist.  If commands are scheduled to run in this time
period, then cron will still execute them at their scheduled time in the stan-
dard time zone, which will be later than expected in the local time zone. cron
will warn the user of this by mail and give the exact local time that the com-
mand will be executed.  It is then the user's responsibility to reschedule the
job if required.
Avatar billede siemen Nybegynder
21. februar 2002 - 20:39 #6
Det er mulig at ocr-scanning gir enkelte feil bokstaver. Gi lyd hvis det er noe du er i tvil om...
Avatar billede nuck Nybegynder
22. februar 2002 - 00:31 #7
Ok det fattede jeg alt 0 af

Jeg vil bare vide hvordan de 2 ting skal se ud hvis den skal kører en PHP fil...
Avatar billede cybermike Nybegynder
23. februar 2002 - 18:09 #8
nuck> Svar på mine spørgsmål, det ville hjælpe.

Hvilken dist.
Hvor ligger php scriptet.
og hvor tit skal det køres.

Den her linie, stiller mit ur en gang hvert tiende minut:
0,10,20,30,40,50        * * * * /usr/sbin/ntpdate ntp1.inet.tele.dk>/dev/null
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
IT-kurser om Microsoft 365, sikkerhed, personlig vækst, udvikling, digital markedsføring, grafisk design, SAP og forretningsanalyse.

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester