Answer by Pawel Cioch for Why crontab scripts are not working?
Crontab PermissionsThere are two files that control the permissions for crontab: /etc/cron.allow and /etc/cron.deny. If there is a cron.allow file, then the user or users that need to use cron will...
View ArticleAnswer by GrayedFox for Why crontab scripts are not working?
The default .bashrc files on UBuntu 16.04 (and many other versions) have a built in mechanism to not do anything if they are not an interactive shell.This can prevent the file from being sourced...
View ArticleAnswer by loxaxs for Why crontab scripts are not working?
You used:* * * * * DISPLAY=:0 /path/to/your/appbut it failed because your ~/.dbus directory is owned not by you but by root. Check it:ls -l ~/.dbus
View ArticleAnswer by AlonL for Why crontab scripts are not working?
Another caveat: Try not to put your cron scripts in a user's home directory.I just had a problem where everything seemed good, but just after a while - probably a few hours after I log out, the cron...
View ArticleAnswer by Dennis Parslow for Why crontab scripts are not working?
On my RHEL7 servers, root cron jobs would run, but user jobs would not. I found that without a home directory, the jobs won't run (but you will see good errors in /var/log/cron). When I created the...
View ArticleAnswer by Kulasangar for Why crontab scripts are not working?
After hours found out the problem where, I was editing the shell script from Windows (notepad++), where the file was originally located in a Linux server and I've missed out the new line...
View ArticleAnswer by Henrik N for Why crontab scripts are not working?
Cron jobs won't run if your user's password has expired.One indication of this is if your cron log (typically /var/log/syslog on Ubuntu, I believe) contains messages like "Authentication token is no...
View ArticleAnswer by Christopher Gonzalez Gonzalez for Why crontab scripts are not working?
In 16.04, if you have this error in syslog(CRON) error (can't fork)try:systemctl status cron.serviceIn the result:Tasks: num_task (limit: 512)If num_task is close to the limit use:systemctl...
View ArticleAnswer by sxc731 for Why crontab scripts are not working?
Sometimes cron is working just fine but the script or command you want it to run just fails silently, causing you to bark up the wrong tree.In such cases I find it useful to wrap the target within...
View ArticleAnswer by Paul for Why crontab scripts are not working?
My crontab only worked when I was logged in as user.I found the solution suggested here on Unix & Linux SEWhat was the problem is that the scrips were in my home directory which was encrypted. So...
View ArticleAnswer by KiloOne for Why crontab scripts are not working?
In my case cron and crontab had different owners.NOT working I had this:User@Uva ~ $ ps -ef | grep cron | grep -v grepUser 2940 7284 pty1 19:58:41 /usr/bin/crontabSYSTEM 11292 636 ? 22:14:15...
View ArticleAnswer by marius-nyxpoint for Why crontab scripts are not working?
I had some issues with using sudo in a cron. Basically I wanted to run a command as a specific user and I tested first, at the command line, su, which returned the error This account is not available....
View ArticleAnswer by Kevin for Why crontab scripts are not working?
Logging PermissionsA very simple crontab, won't execute because /var/log/ is not writable by luser account!* * * * * /usr/local/bin/teamviewer_check >> /var/log/teamviewer.log...
View ArticleAnswer by AlonL for Why crontab scripts are not working?
=== Docker alert ===If you're using docker, I think it is proper to add that I couldn't manage to make cron to run in the background.To run a cron job inside the container, I used supervisor and ran...
View ArticleAnswer by kenorb for Why crontab scripts are not working?
If running scripts within /etc/cron.* directories, make sure your scripts:are executable,match the Ubuntu/Debian cron script namespace (^[a-zA-Z0-9_-]+$).So for example if you've script with extension...
View ArticleAnswer by mahemoff for Why crontab scripts are not working?
Another Gotcha:When you type crontab -e and save inside the editor, it won't have any effect. You have to exit the editor for it to add or update according to your changes (e.g. use :x in Vim).(crontab...
View ArticleAnswer by Philluminati for Why crontab scripts are not working?
If you have a command like this:* * * * * /path/to/script >> /tmp/outputand it doesn't work and you can't see any output, it may not necessarily mean cron isn't working. The script could be...
View ArticleAnswer by erjoalgo for Why crontab scripts are not working?
This happened to me recently: I had two lines that modified PATH, like this:PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/ernesto/binThen, later in the...
View ArticleAnswer by don.joey for Why crontab scripts are not working?
I once was working on a shared server with lots of restrictions. All the answers here (PATH, SHELL, bash -c,...) could not get my script to work in the crontab. It did work perfectly when I put the...
View ArticleAnswer by Martijn de Milliano for Why crontab scripts are not working?
When a task is run within cron, stdin is closed. Programs that act differently based on whether stdin is available or not will behave differently between the shell session and in cron.An example is the...
View ArticleAnswer by Michael Mather for Why crontab scripts are not working?
If crontab mentions something like run-parts /etc/cron.daily, then run-parts may be refusing to run your script. In my case the script in cron.daily did not start with #!/bin/sh.I discovered this by...
View ArticleAnswer by user166286 for Why crontab scripts are not working?
I had a problem with a script that called grep with a regular expression. Some regexs worked when the script was called from crontab while others did not, e.g. [[:print:]] did not work. It turns out...
View ArticleAnswer by Alexandre for Why crontab scripts are not working?
Although you can define environment variables in your crontable, you're not in a shell script. So constructions like the following won't...
View ArticleAnswer by John Peterson for Why crontab scripts are not working?
Insecure cron table permissionA cron table is rejected if its permission is insecuresudo service cron restartgrep -i cron /var/log/syslog|tail -22013-02-05T03:47:49.283841+01:00 ubuntu cron[49906]:...
View ArticleAnswer by JohnGH for Why crontab scripts are not working?
If you are accessing an account via SSH keys it is possible to login to the account but not notice that the password on the account is locked (e.g. due to expiring or invalid password attempts)If the...
View ArticleAnswer by Doug for Why crontab scripts are not working?
If you edited your crontab file using a windows editor (via samba or something) and it's replaced the newlines with \n\r or just \r, cron won't run.Also, if you're using /etc/cron.d/* and one of those...
View ArticleAnswer by allaptr for Why crontab scripts are not working?
I was writing an install shell script that creates another script to purge old transaction data from a database. As a part of the task it had to configure daily cron job to run at an arbitrary time,...
View ArticleAnswer by Mange for Why crontab scripts are not working?
Building off what Aaron Peart mentioned about verbose mode, sometimes scripts not in verbose mode will initialize but not finish if the default behavior of an included command is to output a line or...
View ArticleAnswer by Mange for Why crontab scripts are not working?
Writing to cron via "crontab -e" with the username argument in a line. I've seen examples of users (or sysadmins) writing their shell scripts and not understanding why they don't automate. The "user"...
View ArticleAnswer by Aaron Peart for Why crontab scripts are not working?
cron script is invoking a command with --verbose optionI had a cron script fail on me because I was in autopilot while typing the script and I included the --verbose option: #!/bin/bashsome commandstar...
View ArticleAnswer by Lenik for Why crontab scripts are not working?
The script filenames in cron.d/, cron.daily/, cron.hourly/, etc., should NOT contain dot (.), otherwise run-parts will skip them.See run-parts(8): If neither the --lsbsysinit option nor the --regex...
View ArticleAnswer by Daniel Tet for Why crontab scripts are not working?
It is also possible that the user's password has expired. Even root's password can expire. You can tail -f /var/log/cron.log and you will see cron fail with password expired. You can set the password...
View ArticleAnswer by JMS for Why crontab scripts are not working?
If your crontab command has a % symbol in it, cron tries to interpret it. So if you were using any command with a % in it (such as a format specification to the date command) you will need to escape...
View ArticleAnswer by luissquall for Why crontab scripts are not working?
I had some issues with the time zones. Cron was running with the fresh installation time zone. The solution was to restart cron: sudo service cron restart
View ArticleAnswer by andrew for Why crontab scripts are not working?
If your cronjob invokes GUI-apps, you need to tell them what DISPLAY they should use.Example: Firefox launch with cron.Your script should contain export DISPLAY=:0 somewhere.
View ArticleAnswer by Phil Dodd for Why crontab scripts are not working?
Cron daemon could be running, but not actually working. Try restarting cron:sudo /etc/init.d/cron restart
View ArticleAnswer by Ian Mackinnon for Why crontab scripts are not working?
In many environments cron executes commands using sh, while many people assume it will use bash.Suggestions to test or fix this for a failing command:Try running the command in sh to see if it works:sh...
View ArticleAnswer by pjmorse for Why crontab scripts are not working?
Script is location-sensitive. This is related to always using absolute paths in a script, but not quite the same. Your cron job may need to cd to a specific directory before running, e.g. a rake task...
View ArticleAnswer by BillThor for Why crontab scripts are not working?
The most frequent reason I have seen cron fail in an incorrectly stated schedule. It takes practice to specify a job scheduled for 11:15 pm as 15 23 * * * instead of * * 11 15 * or 11 15 * * *. Day of...
View ArticleAnswer by pbr for Why crontab scripts are not working?
Crontab specs which worked in the past can break when moved from one crontab file to another. Sometimes the reason is that you've moved the spec from a system crontab file to a user crontab file or...
View ArticleAnswer by aneeshep for Why crontab scripts are not working?
Cron daemon is not running. I really screwed up with this some months ago.Type:pgrep cron If you see no number (i.e. cron's main PID), then cron is not running. sudo /etc/init.d/cron start can be used...
View ArticleAnswer by geirha for Why crontab scripts are not working?
Different environmentCron passes a minimal set of environment variables to your jobs. To see the difference, add a dummy job like this:* * * * * env > /tmp/env.outputWait for /tmp/env.output to be...
View ArticleAnswer by user9521 for Why crontab scripts are not working?
Permissions problems are quite common, I'm afraid.Note that a common workaround is to execute everything using root's crontab, which sometimes is a Really Bad Idea. Setting proper permissions is...
View ArticleAnswer by Kangarooo for Why crontab scripts are not working?
Line written in a way crontab doesn't understand. It needs to be correctly written. Here's CrontabHowTo.
View ArticleAnswer by jet for Why crontab scripts are not working?
Cron is calling a script that is not executable.By running chmod +x /path/to/script, the script becomes executable and this should resolve this issue.
View ArticleAnswer by user4124 for Why crontab scripts are not working?
My top gotcha: If you forget to add a newline at the end of the crontab file. In other words, the crontab file should end with an empty line.Below is the relevant section in the man pages for this...
View ArticleAnswer by Adam Matan for Why crontab scripts are not working?
Absolute path should be used for scripts:For example, /bin/grep should be used instead of grep:# m h dom mon dow command0 0 * * * /bin/grep ERROR /home/adam/run.log &> /tmp/errorsInstead of:# m...
View ArticleWhy crontab scripts are not working?
Often, crontab scripts are not executed on schedule or as expected. There are numerous reasons for that:wrong crontab notationpermissions problemenvironment variablesThis community wiki aims to...
View Article