Crontab

Pagina: 1
Acties:

Onderwerpen


Acties:
  • 0 Henk 'm!

  • tj.jackel
  • Registratie: Augustus 2014
  • Laatst online: 21:38
Hallo,

Ik wil dat mijn raspberry pi server twee keer per half uur mijn /var/www/ map scant met clamav en dan een mail stuurt. Echter krijg ik dit niet werkend, ik krijg deze fout code:
Apr 5 10:25:01 "naammachine" /usr/sbin/cron[6691]: (*system*) RELOAD (/etc/crontab)
Apr 5 10:25:01 "naammachine" cron[6691]: Error: bad username; while reading /etc/crontab
Apr 5 10:25:01 "naammachine" /usr/sbin/cron[6691]: (*system*) ERROR (Syntax error, this crontab file will be ignored)

dit is de code:

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
30 01 * * * /usr/bin/freshclam --quiet; /usr/bin/clamscan --recursive --no-summary --infected / 2>/dev/null
26,54 * * * * * /usr/bin/freshclam --quiet; /usr/bin/clamscan --recursive --no-summary --infected --remove /var/www/ 2>/dev/null
MAILTO="mailmailmail@gmail.com"
#

Wat gaat hier fout?

Alvast bedankt.

Acties:
  • 0 Henk 'm!

  • .oisyn
  • Registratie: September 2000
  • Laatst online: 19:58

.oisyn

Moderator Devschuur®

Demotivational Speaker

Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.


Acties:
  • 0 Henk 'm!

  • tj.jackel
  • Registratie: Augustus 2014
  • Laatst online: 21:38
O excuses.

[ Voor 88% gewijzigd door tj.jackel op 05-04-2015 12:41 ]


Acties:
  • 0 Henk 'm!

  • Sendy
  • Registratie: September 2001
  • Niet online
Als je een user /usr/bin/freshclam hebt is er inderdaad geen fout.

Acties:
  • 0 Henk 'm!

  • tj.jackel
  • Registratie: Augustus 2014
  • Laatst online: 21:38
Wordt met user gewoon een inlog user bedoelt of valt hier iets anders onder? Want die user heb ik niet.

[ Voor 15% gewijzigd door tj.jackel op 05-04-2015 12:44 ]


Acties:
  • 0 Henk 'm!

  • Sendy
  • Registratie: September 2001
  • Niet online
Dat is de user waaronder het programma draait. Je hebt geen user gespecificeerd dus denkt cron nu dat je /usr/bin/freshclam als user bedoeld. En dat is geen geldige username ("bad username")

Acties:
  • 0 Henk 'm!

  • Blokker_1999
  • Registratie: Februari 2003
  • Laatst online: 20:36

Blokker_1999

Full steam ahead

zoals de crontab file die je aan het editen bent trouwens zelf aangeeft:
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do
.
Waarom bewerk je trouwens deze file en niet gewoon de user specifieke crontab?

No keyboard detected. Press F1 to continue.


Acties:
  • 0 Henk 'm!

  • Kanarie
  • Registratie: Oktober 2000
  • Laatst online: 20:06

Kanarie

תֹ֙הוּ֙ וָבֹ֔הוּ

code:
1
26,54 * * * * * /usr/bin/freshclam --quiet; /usr/bin/clamscan --recursive --no-summary --infected --remove


1 * teveel.

We're trapped in the belly of this horrible machine. And the machine is bleeding to death.


Acties:
  • 0 Henk 'm!

  • tj.jackel
  • Registratie: Augustus 2014
  • Laatst online: 21:38
Hallo,

Ik heb de punten verwerkt en krijg nu dit:

Apr 5 11:26:01 pinaam /USR/SBIN/CRON[3801]: (root) CMD (/usr/bin/freshclam --quiet; /usr/bin/clamscan --recursive --no-summary --infected --remove /var/www/ 2>/dev/null)

Echter wordt er geen mail verstuurd. Is dit omdat er niks gevonden is? Ik zou ook graag een mail hebben als er niks gevonden wordt.

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
30 01 * * * root /usr/bin/freshclam --quiet; /usr/bin/clamscan --recursive --no-summary --infected / 2>/dev/null
26,54 * * * * root /usr/bin/freshclam --quiet; /usr/bin/clamscan --recursive --no-summary --infected --remove /var/www/ 2>/dev/null
MAILTO="eenmailadres@gmail.com"

Acties:
  • 0 Henk 'm!

  • CAPSLOCK2000
  • Registratie: Februari 2003
  • Laatst online: 21:28

CAPSLOCK2000

zie teletekst pagina 888

Is er wel output als je het commando met de hand draait? Of er ook output is als er niks wordt gevonden zal je in de handleiding moeten opzoeken of zelf uitproberen. Als er geen output is als er niks gevonden wordt zal je er iets om heen moeten scripten.

Ik neem aan dat je weet je wat 2>/dev/null doet en dat je dat doelgericht gebruikt? Anders moet je dat even uitzoeken.


PS. Zet aub de console en logberichten tussen code-tags, dat maakt het voor ons makkelijker leesbaar.

[ Voor 29% gewijzigd door CAPSLOCK2000 op 05-04-2015 13:46 ]

This post is warranted for the full amount you paid me for it.


Acties:
  • 0 Henk 'm!

  • tj.jackel
  • Registratie: Augustus 2014
  • Laatst online: 21:38
Volgens mij moet het 2>/dev/null weg toch? Schijnt het weg gooien van informatie te zijn.

Acties:
  • 0 Henk 'm!

  • Hero of Time
  • Registratie: Oktober 2004
  • Laatst online: 22:47

Hero of Time

Moderator LNX

There is only one Legend

Zoek maar eens op console redirect en de verschillen tussen stdout, stdin, stderr e.d. Lees ook eens de verschillende man-pages van cron.

Commandline FTW | Tweakt met mate

Pagina: 1