Jump to content

Dodawanie zadania do Crone


Guest pablik

Recommended Posts

Guest pablik

Witam, chciałem dodać wykonanie zadania przez Crona, lecz tu nie ma pliku crontab, utworzyłem taki sam jak w debianie wstawiłem go do /etc/ przewaliłem crona lecz nie działa.

Może tu gdzie indziej przechowany jest plik cronetab lub zadania są przechowywane w innym pliku ???

 

cat /etc/crontab

# /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
25 * * * * root  /root/skrypt.py &

Link to comment
Share on other sites

Guest pablik

Dalej nie działa, wywaliłem ten mój plik, dodałem wpis przez crontab -e, następnie /etc/init.d/cron restart i nic ;(

 

# /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
53 * *   *   *   root  /root/skrypt.py

 

Link to comment
Share on other sites

Dalej nie działa, wywaliłem ten mój plik, dodałem wpis przez crontab -e, następnie /etc/init.d/cron restart i nic ;(

 

Sprawdź, czy skrypt ma uprawnienia do wykonywania (lub wykonaj w ciemno "chmod +x" na pliku).

 

Dodatkowo, w pierwszej linii skryptu powinieneś mieć deklarację interpretera, w stylu:

 

#! /usr/bin/env python

Link to comment
Share on other sites

Guest pablik

Tak, jeśli uruchomię skrypt /root/skrypt.py to działa normalnie. Coś jest nie tak z cron'em ponieważ zmieniłem zdanie na utworzenie pliku lecz go nie tworzy:

# /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
12 * *   *   *   root  touch /root/test

 

Link to comment
Share on other sites

Guest pablik

Dalej nic:

# /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
20 * * * * root touch /root/test

Link to comment
Share on other sites

Guest pablik

Nie wiem ja tego pliku nie tworzyłem


Scalono wiadomość: [time]1494100525[/time]

Chyba mam rozwiązanie, coś musiałem namieszać z plikiem bo przeinstalowałem softa i całkiem inaczej wygląda, sprawdzę teraz i dam znać czy wszystko jest ok. 

 

Tak, działa już poprawnie, wstawie tu orginał może komuś sie przyda.

#             -----          --------------
#              minute         0-59
#              hour           0-23
#              day of month   1-31
#              month          1-12 (or names, see below)
#              day of week    0-7 (0 or 7 is Sunday, or use names)

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
NICE=15

# run-parts
*/1 * * * *       /bin/run-parts /etc/cron/minutely
01 * * * *       /bin/run-parts /etc/cron/hourly
02 5 * * *       /bin/run-parts /etc/cron/daily
03 2 * * 0       /bin/run-parts /etc/cron/weekly
04 3 1 * *       /bin/run-parts /etc/cron/monthly

# your corntabs

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...