Friday, April 26, 2024
 Popular · Latest · Hot · Upcoming
27
rated 0 times [  27] [ 0]  / answers: 1 / hits: 141346  / 1 Year ago, wed, february 1, 2023, 1:28:03

I have created a file called ntpdate in /etc/cron.hourly



#!/bin/sh
/usr/sbin/ntpdate-debian
date > /tmp/william_tmp
date > /william_tmp
date > ~/william_tmp
echo test


I also did Chmod 755 to this file.



However, I can't tell if the file has run or not!



The file is not created in any of the 3 directories.



If I manually run cd / && run-parts --report /etc/cron.hourly then the files are created and I get the echo.



Can anyone recommend (ideally step by step!) instructions to test that it is working?


More From » server

 Answers
6

One major pitfall to cron is cron runs in an extremely limited shell environment, as a result a lot of variables aren't exported in to the environment, mainly $PATH. Make sure you use all absolute paths to executable, including common functions like echo, uptime, date, etc all need to use full paths (/bin/echo, /bin/date, /usr/bin/uptime). To determine the path to an executable, you can use the which command like so: which echo - this will show you the full path to that tool.


[#37705] Thursday, February 2, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eryeath

Total Points: 122
Total Questions: 121
Total Answers: 112

Location: Saint Helena
Member since Fri, Aug 26, 2022
2 Years ago
;