Hey folks,
I've got a weird problem on my free ESXi 6.7u3 Hypervisor regarding CRON.
I created a new user called "michael" with administrator privileges via the web-interface. Furthermore assigned the role "no access" to the "root" user (for hardening purposes).
Now i created the file /var/spool/cron/cronjobs/michael per SSH and pasted a simple command to test it (echo). The crontab-file looks as follows:
[michael@esxi:~] cat /var/spool/cron/crontabs/michael
28 13 * * * /bin/echo "test" > /vmfs/volumes/Backup/log.txt
Then I killed the cron daemon, restarted it again and just waited until the time is over and watched the syslog.log:
[michael@esxi:~] kill $(cat /var/run/crond.pid)
[michael@esxi:~] crond
[michael@esxi:~] tail -f /var/log/syslog.log
[...]
2020-01-07T13:28:00Z crond[2108571]: USER michael pid 2108578 cmd /bin/echo "test" > /vmfs/volumes/Backup/log.txt
As you can see from the output above, the cronjob is firing properly, but no text file has been created on the given directory!
[michael@esxi:~] cat /vmfs/volumes/Backup/log.txt
cat: can't open '/vmfs/volumes/Backup/log.txt': No such file or directory
The path is correct and if I execute the command on myself in SSH, the text file will be created.
This problem also occurs when trying other cronjobs (like starting guest VMs).
Does anyone of you know why this is not working?
Thank you in advance,
Michael
Hi,
I have the same problem, the cron job is fired but fail...
the cron is defined like:
10 02 * * * /sbin/buESXi.sh > /vmfs/volumes/uSrvVMs/_BU_/_cron.log 2>&1
[root@ESXi:~] cat /vmfs/volumes/uSrvVMs/_BU_/_cron.log
/bin/sh: /sbin/buESXi.sh: not found
[root@ESXi:~] ls -lh /sbin/buESXi.sh
lrwxrwxrwx 1 root root 64 Nov 13 14:23 /sbin/buESXi.sh -> /vmfs/volumes/2510ee9d-8652ba80-0000-000000000000/_BU_/buESXi.sh
I tried both with the datastore id and the datastore name (/vmfs/volumes/uSrv/_BU_/buESXi.sh)
[root@ESXi:~] ll /vmfs/volumes/uSrvVMs/_BU_/buESXi.sh
-rwxrwxrwx 1 root root 2.0K Nov 11 17:03 /vmfs/volumes/uSrvVMs/_BU_/buESXi.sh
I also tried to define the cron like this:
10 02 * * * /vmfs/volumes/uSrvVMs/_BU_/buESXi.sh > /vmfs/volumes/uSrvVMs/_BU_/_cron.log 2>&1
[root@ESXi:~] cat /vmfs/volumes/uSrvVMs/_BU_/_cron.log
/bin/sh: /vmfs/volumes/uSrvVMs/_BU_/buESXi.sh: not found
what is strange to me is that the log file (_cron.log) is created on the NFS 4 mounted datastore, but the execution says that the sh file doesn't exists...
After 3 days of trying everything I could think of, any help would be welcome.
Thanks,
Johan.
After some more tests, I finally found a solution: /bin/sh.
In the cron job definition, I now have:
10 02 * * * /bin/sh /bin/buESXi.sh > /vmfs/volumes/uSrvVMs/_BU_/_cron.log 2>&1
where /bin/buESXi.sh is a symbolic link to /vmfs/volumes/uSrvVMs/_BU_/buESXi.sh
I have no explanation why I have to indicate /bin/sh since another entry in the cron file is
1 * * * * /sbin/auto-backup.sh
and it gets executed....
anyway, my job gets executed and it's all that matters to me.