|
Search |
Linuxissa voit kirjoittaa skriptejä jotka suoritetaan tiettynä aikana. Ajoitettujen tehtävien konfigurointi Konfigurointitiedosto cron-tehtäviä varten on /etc/crontab. Se sisältää seuraavat rivit: SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly Ensimmäiset neljä riviä määrittelevät ympäristön ajoitetuille tehtäville. SHELL-muuttuja kertoo mitä shell:iä käytetään (esimerkissä: BASH). PATH-muuuttuja kertoo käytettävän polun komentojen suorittamiselle. Tehtävien tulokset sähköpostitetaan MAILTO-osoitteeseen. Tyhjä argumentti (MAILTO="") ei lähetä mitään. HOME-muuttujalla voi valita kotihakemiston josta komennot ja skriptit ajetaan. Jokainen rivi /etc/crontab-tiedostossa on muodossa: minuutti tunti päivä kuukausi viikonpäivä komento
"*"-merkkiä voi käyttää jokerimerkkinä. Esimerkiksi * kuukauden kohdalla suorittaa komennon joka kuukausi. "-"-merkki määrittelee jonon. 1-4 tarkoittaa jonoa 1,2,3,4. A list of values separated by commas (,) specifies a list. For example, 3, 4, 6, 8 indicates those four specific integers. The forward slash (/) can be used to specify step values. The value of an integer can be skipped within a range by following the range with / Any lines that begin with a hash mark (#) are comments and are not processed. How to start an automatic execution of a script on hosting plan? First it needs to be verified whether the script works in shell mode. In order to do it you need to place #!/usr/local/bin/php, for php script, #!/usr/bin/perl, for perl, lub #!/bin/bash, for shell script. Then use chmod 700 skrypt.cgi command for the script. If you have telnet/ssh access you may check it by./script.cgi. Remember to use cd /home/login command at the beginning of the script. You may use absolute path to indicate the file. After verification of the script in shell mode, you need to contact Client Service Panel by email and provide the following data:
|