1

I have an Ubuntu 14.04.5 installed and I'm trying to run a cron but it does not work.

$ whoami
root

$ crontab -e
#append at the end of the file
* * * * * env > /tmp/env_root.output
#save and quit :wq

$ less /var/log/cron.log
......
Sep 22 20:15:01 myserver CRON[2993]: (root) CMD (env > /tmp/env_root.output)

$ ls -la /tmp/env_root.output
ls: cannot access /tmp/env_root.output: No such file or directory

Why is this? I am root and I should be able to edit files, the Cron log shows it as being changed, but no file is there. If I run the command in the current GNU BASH shell or even in /bin/sh it works but not in Cron.

What am I doing wrong? Does Ubuntu have something like SELinux that I might have enabled by mistake? I provision my server with Ansible and I am not the only person working on the Ansible roles.

Thank you

EDIT: This is how my /etc/crontab looks and it runs /usr/bin/myscript.sh https://paste.fedoraproject.org/433591/74650461/

pa4080
  • 30,621
ddreian
  • 293

1 Answers1

-1

The best way to troubleshoot cron jobs is to watch the cron output in near-real-time.

This Q&A describes the process of breaking out syslog to make the system create a cron.log and to monitor it:

16.04: How do I make cron create cron.log and monitor it in real time?

It is very helpful to change the log level to 15 so it not only shows start times but also errors and stop times:

How to change cron log level?

SDsolar
  • 3,219