Linux no crontab for user

unixforum.org

Есть подозрение, что cron не запускает команды.
В /etc/crontab правила есть, а команда «crontab -u root -l» говорит «no crontab for root».
Так не должно быть?

Bizdelnick Модератор Сообщения: 20389 Статус: nulla salus bello ОС: Debian GNU/Linux

Re: cron не работает

Сообщение Bizdelnick » 15.07.2016 12:46

Всё правильно. /etc/crontab — это не crontab рута, и синтаксис у него отличается от пользовательских crontab’ов: в нём должно быть дополнительное поле, где указывается пользователь, от имени которого запускается команда.

в консоли
вку́пе (с чем-либо)
в общем
вообще
в течение (часа)
новичок
нюанс
по умолчанию
приемлемо
проблема
пробовать
трафик

sunny1983 Сообщения: 357 ОС: GNU/Linux 4.x (Fedora, Debian) Контактная информация:

Re: cron не работает

Сообщение sunny1983 » 18.07.2016 10:47

Всё правильно. /etc/crontab — это не crontab рута, и синтаксис у него отличается от пользовательских crontab’ов: в нём должно быть дополнительное поле, где указывается пользователь, от имени которого запускается команда.

Я не про пользовательский, а про рутовый кронтаб спрашивал. Или нет разницы?
Так собственно у меня вопрос, будет ли работать, если «crontab -u root -l» ничего не показывает, а в /etc/crontab следующее:

SHELL=/bin/sh PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin */5 * * * * root /usr/libexec/atrun */15 * * * * root /usr/local/bin/python /usr/utm/main.py */11 * * * * operator /usr/libexec/save-entropy 0 * * * * root newsyslog 1 3 * * * root periodic daily 15 4 * * 6 root periodic weekly 30 5 1 * * root periodic monthly 1,31 0-5 * * * root adjkerntz -a

Источник

How to fix it **no crontab for root — using an empty one 888**? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

I want to set cron in ubuntu server,but when I run command crontab -e, I see this status or error. no crontab for root — using an empty one 888 How can I fix this.

Stack Overflow is for programming questions, not questions about using or configuring Linux and its applications. Super User or Unix & Linux would be better places for questions like this.

Читайте также:  Debian подключить сетевой диск linux

It should give you an empty editor buffer, you add the new crontab lines you want. When you save it out, root has a crontab.

Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Super User or Unix & Linux Stack Exchange would be a better place to ask.

3 Answers 3

I know what you mean, it shows a line «888» when you run command crontab -e . That’s because you chose /bin/ed as your editor, but you are not familiar with it.

Just vi ~/.selected_editor , you’ll see it and change the value to /usr/bin/vi .

Then run command crontab -e again, it will be what you want.

Your crontab editor has been switched to ed. To exit ed, press Q and subsequently Enter . This will quit the ed editor.

If you would like to change your crontab editor back to nano, use:

This also might be helpful:

Источник

no crontab for [username] — using an empty one

I want to run a bash file ( abc.sh ) on the desktop that runs a python file on the desktop as well. How can I do that? I tried to do the following simple task just to test the crontab: (here the abc.sh script is supposed to make a folder on the desktop): What I did on Terminal:

#!/bin/bash cd /home/ebrisk/Desktop mkdir "testcrontab" 

I understand that it might have to do something with the PATH environment variables but that’s about it. I don’t understand their answers.

2 Answers 2

Be sure to make the scipt with execute permission

Here is what I did: On the Terminal ‘chmod +x /path/to/scripts/abc.sh’ then sudo crontab -e Under the line m h dom mon dow command I Entered * * * * * sh /path-to-your-script/abc.sh ___ No folder was created on the desktop

you have to state at which minute and hour you want to run so you have to put for example 10 8 * * * sh /path-to-your-script/abc.sh

with * * * * * should it not do that every minute? I did put in the time any ways but still, no folder was created on the desktop.

Here is the new code in abc.sh #!/bin/bash cd /home/ebrisk/Desktop/ mkdir «testcrontab» echo «blahblahblah» ___ and nothing happened

I had the same problem. I figured out while I selected an editor to create my cron jobs, I always used to rename the files with a suitable name I could identify. This time around I kept the name as suggested by system and did not rename the file. This is first time I was using crontab on my system. And it worked. I saw o/p on terminal saying installing crontab. So for the first time I think you have to go with the suggested name.

Читайте также:  Setup dns servers linux

You must log in to answer this question.

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.17.43535

Ubuntu and the circle of friends logo are trade marks of Canonical Limited and are used under licence.

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

Terminal returning: no crontab for user

I create a new user, john. Now I want to programmatically write a cronjob to the user john’s crontab.

#!/bin/bash #script name: cronbuild.sh cronjob1="0 */3 * * * /home/john/ad_dev/modem_dog.sh" < crontab -l -u john; echo "$cronjob1"; >| crontab -u john - 
tony@rpi:~ $: sudo ./cronbuild.sh no crontab for user tony@rpi:~ $ 
tony@rpi:~ $: sudo crontab -u john -l 0 */3 * * * /home/john/ad_dev/modem_dog.sh tony@rpi:~ $: 

because it in fact does not have a crontab. Seems obvious and not helpful. So my question, why is it stating no crontab for user.

1 Answer 1

The message is from crontab -l -u john you used in the script.

On one hand you did use the command. The only(?) reason to use it is to preserve the old crontab and append to it (not just overwrite it). This may be a good decision if there is an old crontab with arbitrary content you want to keep. This may be a bad decision if you run the script multiple times (lines you’re adding will accumulate).

On the other hand you’re saying the message is «obvious and not helpful», I guess because you know the user does not have a crontab (yet). But if you know for sure there is no crontab, then there is no need for crontab -l … in the first place. So maybe you don’t need it.

The fact you used the command can be interpreted as if you expected (or at least allowed) the crontab to exist. So it’s reasonable to warn you if it doesn’t exist. This is what the command does. You can suppress the message by sending the stderr to /dev/null :

Источник

crontab -e does not open the crontab for this user

I had set up a few jobs using crontab a few months back and they had been working well up until a few days ago, I noticed one had not run. I just tried to check the crontab file using the user that created the jobs, using crontab -e , and no file opens. Terminal quickly flitts tosome screen and then back to the screen where I had entered the command. It goes and comes back too quickly for me to see what is there. I have (as sudo) checked under /var/spool/cron/crontab/ and see there is a file for the mentioned user, which contains the basic:

> DO NOT EDIT THIS FILE - edit the master and reinstall. > (- installed on Wed Mar 21 00:12:22 2018) > (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $) 

I notice that the isntall date is pretty much exactly where my cron jobs stopped! Maybe the system needed a restart for some reason. I restarted the machine and again tried: crontab -e , this time I got the following error coming from Emacs (the default editor, I believe):

emacsclient: can't find socket; have you started the server? To start the server in Emacs, type "M-x server-start". Warning: due to a long standing Gtk+ bug http://bugzilla.gnome.org/show_bug.cgi?id=85715 . [truncated] 
user@user:~$ select-editor Select an editor. To change later, run 'select-editor'. 1. /bin/ed 2. /bin/nano  

This just gave the same problem as initially described - it shortly seemed to open a file then close it again. Is there another way to debug and (hopefully) get back the original crontab file? The jobs were quit complex to set up (see note #2 below) :-/ I tried to find running crontab tasks using this answer, so cron is running, but what about my crontab tasks?

user@user:~$ ps -o pid,sess,cmd afx | egrep "( |/)cron( -f)?$" 1077 1077 /usr/sbin/cron -f 

Other notes:

  • anacron is installed
  • the cron jobs themselves are defined in the crontab file, not via external scripts
  • one cronjob used a virtual env, which does still exist and works and I can execute the job manually

Updates:

The output from some further checks (mostly requested by @steeldriver)

user@user:~$ ls -l $(which crontab) -rwxr-sr-x 1 root crontab 36080 Apr 5 2016 /usr/bin/crontab 

Is that the setuid s in there? I compared it to ping , because I read that should have some kind of elevated permissions:

user@user:~$ ls -l $(which ping) -rwsr-xr-x 1 root root 44168 Mai 7 2014 /bin/ping 
user@user:~$ sudo crontab -e [sudo] password for user: no crontab for root - using an empty one No modification made 

Trying the desired command as sudo, using the user's setup:

user@user:~$ sudo -H -u user bash -c 'crontab -e' No modification made 

Checking if permissions for the entire spool are as expected:

user@user:~$ ls -ld /tmp drwxrwxrwt 16 root root 36864 Apr 1 14:22 /tmp user@user:~$ sudo namei -l /var/spool/cron/crontabs/$USER f: /var/spool/cron/crontabs/user drwxr-xr-x root root / drwxr-xr-x root root var drwxr-xr-x root root spool drwxr-xr-x root root cron drwx-wx--T root crontab crontabs -rw------- user crontab user 

Источник

Оцените статью
Adblock
detector