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.
-
This may help: superuser.com/questions/359580/… My problem was resolved.Daebarkee– Daebarkee2017年04月28日 19:09:11 +00:00Commented Apr 28, 2017 at 19:09
7 Answers 7
That's probably because this user does not have a crontab, yet. You can create a crontab for this user by calling:
crontab -e
-
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– john smith2015年06月28日 15:21:57 +00:00Commented 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– john smith2015年06月28日 15:28:02 +00:00Commented Jun 28, 2015 at 15:28
-
mac users see: superuser.com/a/540693/928461stevec– stevec2020年11月02日 21:54:41 +00:00Commented 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– Talha Imam2022年03月04日 16:45:28 +00:00Commented Mar 4, 2022 at 16:45
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
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.
-
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– john smith2015年06月28日 16:37:54 +00:00Commented Jun 28, 2015 at 16:37
-
After adding job to crontab, what is the result of crontab -l? @johnsmithunsung– unsung2015年06月29日 10:23:41 +00:00Commented Jun 29, 2015 at 10:23
-
2Hi 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– john smith2015年06月30日 10:11:36 +00:00Commented Jun 30, 2015 at 10:11
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.
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.
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
-
1Welcome to the site, and thank you for your contribution. Please note that brevity is acceptable, but fuller explanations are better. You may want to add a note why you think this approach will solve the OPs problem.AdminBee– AdminBee2021年11月15日 13:21:30 +00:00Commented Nov 15, 2021 at 13:21
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/
-
1This actually doesn't answer the question since author ot the question already performed these stepsmrc02_kr– mrc02_kr2019年06月25日 10:25:58 +00:00Commented Jun 25, 2019 at 10:25