Curiosità sui cron

Ciao a tutti,

Volevo chiedere circa Crontab, sarei curioso di sapere se è necessario inserire l’utente che esegue il comando se questo è root, ho notato che funziona in entrambi i casi.

Poichè cron viene eseguito di default da root, ha senso metterlo? capirei se fosse necessario l’esecuzione con un utente diverso.

Vi posto due esempi:

[code] 5 1 1-31/2 * * /opt/service/bin/service-postgresql pg-data-purge test public 40

01 01 * * * root /opt/service/bin/service-postgresql pg-data-purge test integration 40 [/code]

Da

$ man 5 crontab

si legge:

The format of a cron command is similar to the V7 standard, with a number of upward-compatible extensions. Each line has five time-and-date fields followed by a username (if this is the system crontab file), and followed by a command.

Cio’ significa che se stai modificando uno degli script di cron presenti in /etc/cron.*, ci va il nome dell’utente (altrimenti non sa con che utente eseguire il comando); se invece stai modificando un crontab di un utente, non serve specificare lo username: ad es. se stai usando ‘# crontab -e’ oppure ‘# crontab -u antowen -e’ non serve l’utente, perche’ hai gia’ spiegato in quale utente “piazzare” questi cron.

Vedi anche: https://help.ubuntu.com/community/CronHowto#Two_Other_Types_of_Crontab