22

I'm seeing an error every time I do the command below. Why?

$crontab -l
no crontab for server

where server is the user account.

This issue comes about because the script in crontab doesn't work, so I've tried to break down the problem. This is what I have put in using crontab -e:

crontab -e
@reboot /usr/bin/teamspeak3-server_linux-amd64/ts3server_minimal_runscript.sh

I press ctrl + o and save it, reboot and find the script doesn't boot (even though the script itself does work if I double click it from the GUI). If I do a crontab -l after the reboot, I find I get the same error as above. Even before the reboot, if I try and open the crontab -e just after I saved this command inside of the file, the line of code isn't there.

1

7 Answers 7

36

That's probably because this user does not have a crontab, yet. You can create a crontab for this user by calling:

crontab -e
4
  • Ok I will update my question with some more info about my problem. Please, I beg you so much to help me fix it.
    – john smith
    Jun 28, 2015 at 15:21
  • Ok I have updated my question to be more specific to the problem I'm facing. See if you can help. I'm really struggling here.
    – john smith
    Jun 28, 2015 at 15:28
  • mac users see: superuser.com/a/540693/928461
    – stevec
    Nov 2, 2020 at 21:54
  • Thank you, I thought I could just go into the terminal and write a command and it will get automatically added to the crontab without having the need to create it. Your answer helped put things into perspective.
    – Talha Imam
    Mar 4, 2022 at 16:45
8

If you get the message "No crontab for username" type the following:

sudo crontab -u username -e

You will be asked to select an editor from a menu. Then a default file will open.

Save the file without naming it.

To check that the file was successfully created type:

crontab -l
0
3

The user server does not have any schedule job in crontab so crontab -l outputs that information, not an error. Normally, you can find a user's crontab file in directory /var/spool/cron/crontabs.

3
  • The reason it doesn't is because I can't make a job in that file that it remembers. I've updated my post, please check it now.
    – john smith
    Jun 28, 2015 at 16:37
  • After adding job to crontab, what is the result of crontab -l? @johnsmith
    – unsung
    Jun 29, 2015 at 10:23
  • 2
    Hi I have fixed this now. It turns out the actual root cause of the problem was that I was using ctrl+z to close nano (sends process to background) rather than ctrl+x, so the cron job was not installing.
    – john smith
    Jun 30, 2015 at 10:11
0

For me this was a silly mistake, I was setting up a cron using sudo and then running the crontab -l without sudo, so I was setting up the cros on root a/c and checking on the user's account due to which it was not finding the crons which were set up.

When I ran sudo crontab -l it gave me all the crons which had been set up correctly.

0

In my case (Oracle Linux) it was complaining about the absence of files under /tmp/ It turned out that the folder was removed earlier. After creating /tmp again - it works like a charm. I hope it'll help someone.

-1

Here's the syntax or example for given problem:

`root@tacktile-desktop:/home/tacktile/Downloads# (crontab -u root -l ; echo "*/2 * * * * /usr/sbin/logrotate /etc/logrotate.conf") | crontab -u root -`

root@tacktile-desktop:/home/tacktile/Downloads# crontab -l */5 * * * * /usr/sbin/logrotate /etc/logrotate.conf */5 * * * * //usr/bin/bash /usr/binaries/scripts/tomcatlogs.sh */5 * * * * /usr/bin/bash /usr/binaries/scripts/tomcatlogs.sh */5 * * * * /usr/sbin/logrotate /etc/logrotate.conf */2 * * * * /usr/sbin/logrotate /etc/logrotate.conf

1
-3

Your crontab not run. You need to run your command on the root with 4 steps:

Step 1: crontab -e
Step 2: o (o in alphabet)
Step 3: Fill your command. Ex: */2 * * * * root /usr/local/auto/restart.sh >/dev/null 2>&1 
Step 4: Exit

ESC :wq Enter

Review your CMD –> crontab -l . It was saved here(/var/spool/cron)

Source: https://thuthuatcaidat.com/sua-loi-no-crontab-for-root/

1
  • 1
    This actually doesn't answer the question since author ot the question already performed these steps
    – mrc02_kr
    Jun 25, 2019 at 10:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .