(Italiano) Cron e Jenkins

 

Se vi trovare di fornte ad azioni ricorrenti

 

quali  fare un back up, allora potete usare cron.

Si può instalare cron su Ubuntu 16.04 (Xenial Xerus) con seguenti comandi da bash:

$ sudo apt-get update
$ sudo apt-get install cron

E vedere se è attivo con

$ service cron status

 

Per fare agire cron, si deve specificagli che deve fare.

Inserisci uno script di shell in una di queste cartelle: /etc/cron.daily, /etc/cron.hourly, /etc/cron.monthly o /etc/cron.weekly.
Uno script è un file che esegue comandi, che comincia con  #!, seguito dalla posizione dell’interperter, tipo:

#! /bin/bash
echo 'hello, world'

 

Se vuoi un grado di dettaglio maggiore è possibile aggiungere attività più specifiche, ad esempio. Due volte al mese o ogni 5 minuti.

Dal terminale,  digita:

$ crontab -e

La schermata di default di crontab:

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use ‘*’ in these fields (for ‘any’).#
# Notice that tasks will be started based on the cron’s system
# daemon’s notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#

 

Quindi se vogliamo una volta alla settimana, usa

@weekly – Shorthand for 0 0 * * 0

vedi altre possibilità.

Questo aprirà il tuo crontab personale (file di configurazione cron), la prima riga in quel file spiega tutto (non pensi)! In ogni riga è possibile definire un comando da eseguire, e il formato è abbastanza semplice quando si ottiene l’appendenza. Così la struttura è:

Minuti di giorno del mese di mese mese di comando del giorno

 

 

up vote
435
down vote
accepted
Put a shell script in one of these folders: /etc/cron.daily, /etc/cron.hourly, /etc/cron.monthly or /etc/cron.weekly.

If these are not enough for you you can add more specific tasks eg. twice a month or every 5 minutes or… go to the terminal and type:

crontab -e
this will open your personal crontab (cron configuration file), the first line in that file explains it all (don’t you think)! In every line you can define one command to run, and the format is quite simple when you get the hang of it. So the structure is:

minute hour day-of-month month day-of-week command

 

 

https://askubuntu.com/questions/2368/how-do-i-set-up-a-cron-job

 

Anche con jenkins si possono programmare azioni

http://stackoverflow.com/questions/12472645/how-to-schedule-jobs-in-jenkins

ma anche molto di piç.

 

 

Introduction to Jenkins: An Open Source Continuous Integration Server

 

 

integrazione continua (continuous integration in inglese, spesso abbreviato in CI) è una pratica che si applica in contesti in cui lo sviluppo del software avviene attraverso un sistema di versioning. Consiste nell’allineamento frequente (ovvero “molte volte al giorno”) dagli ambienti di lavoro degli sviluppatori verso l’ambiente condiviso (mainline).[1]

 

 

http://www.tutorialspoint.com/jenkins/

 

 

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *