Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    eseguire due comandi ogni giorno

    ciao!
    avrei bisogno di una mano con uno script per cron...

    devo fare eseguire tutti i giorni (nn importa a che ora) i comandi:

    # ntpdate ntp1.ien.it
    # hwclock


    mi sapete dare una mano? mai usato cron, il server in questione è troppo importante per provare dopo una semplice lettura di man
    mi fid di voi

  2. #2
    Utente di HTML.it L'avatar di cacao74
    Registrato dal
    Jan 2005
    Messaggi
    2,570
    'nnamo bene!

    solitamente si ha a disposizione una configurazione di cron di pronto utilizzo con directory per i task orari, giornalieri, settimanali e mensili, nonche' un file crontab predisposto.

    A seconda della distro utilizzata queste impostazioni possono variare.

    Esempio per slack di /var/spool/cron/crontab/root
    codice:
    # 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
    Un file simile su Debian lo troviamo in /etc/crontab

    Sempre in /etc troviamno le seguenti dir:
    codice:
    [sergio@winnie ~]$ ls -ld /etc/cron.*
    drwxr-xr-x  2 root root  80 2005-03-20 22:02 /etc/cron.d
    drwxr-xr-x  2 root root 328 2005-03-20 22:02 /etc/cron.daily
    drwxr-xr-x  2 root root  80 2005-03-20 22:02 /etc/cron.hourly
    drwxr-xr-x  2 root root 136 2005-03-20 22:28 /etc/cron.monthly
    drwxr-xr-x  2 root root 152 2005-03-20 22:27 /etc/cron.weekly
    Ora, puoi creare uno script bash in cui raccogli i comandi
    per l'esecuzione del task quotidiano:
    codice:
    #!/bin/bash
    #
    # /etc/cron.daily/clock
    #
    # update clock from remote NTP server
    
    ntpdate ntp1.ien.it
    hwclock
    Salvi questo script in /etc/cron.daily/clock e automagicamente verrà eseguito nell'orario impostato in crontab, nell'esempio di cui sopra, alle ore 4:40 di ogni giorno.

    Questo è quanto. Dovrebbe essere corretto, spero.

    ciao.
    slack? smack!

  3. #3
    grazie mille, provo subito

    (hai la sfera di cristallo? dovevo giusto metterlo su una slack e una debian )

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.