May 27, 201313 yr Hello everybody. I have a dyndns script located at /boot/dyndns.sh I would like to automatically run this script every hour. I have read a lot of threads and the wiki entry, but I don't really understand the combination of go-script and cron. I know of have to write something into the go-script that will invoke cron to run, but I don't know what to write exactly. Thanks and help me learn please
May 27, 201313 yr Add this line to your /boot/config/go script: echo "25 * * * * /boot/dyndns.sh" >> /var/spool/cron/crontabs/root When the go script is run at startup, this line will be added to cron: 25 * * * * /boot/dyndns.sh Which will run the script at /boot/dyndns.sh every hour 25 minutes after the hour. If you prefer to run the script at a different time hourly (such as 1 minute after the hour, change the 25 to 1).
May 27, 201313 yr If you end up needing to add several lines (multiple scripts) to cron, you can create a file containing all the commands (I created /boot/custom/mycron). Then instead of using echo, I cat the file to cron like this: cat /boot/custom/mycron >> /var/spool/cron/crontabs/root Make sure that you are using 2 greater than symbols ">>", which will append your additions to cron while leaving existing commands in cron. If you use a single greater than symbol ">", you will overwrite the contents of cron. If you would like to know a little more about cron, http://en.wikipedia.org/wiki/Cron has some good information. If you still have questions, let me know.
May 27, 201313 yr Author Thanks for the quick answer! I am not sure, but your answer may be wrong. If I understood Joes edit in this post lime-technology.com/forum/index.php?topic=6593.msg63837#msg63837#msg63837 right, he mentions not to use the...........crontab/root command. Did I get it right? Edit: I am on the latest RC version.
May 27, 201313 yr That is an old post from 2010 & it appears that it was for unRAID 4.x (since the edit mentions 5.x versions to do something different). The method I suggested is working on my unRAID server & I have no errors. I've used this in several unRAID 5.x versions. The method listed in the thread you linked seems to be a much longer way of accomplishing the same task. It copies out the existing cron to a temporary file then adds new lines to the temporary file then copies the entire temporary file back into cron. My second post in this thread is an easier way to add multiple lines to cron... but there is more than one way to accomplish every task. Another thing that is different is that "/var/spool/cron/crontabs/root-" is used instead of "/var/spool/cron/crontabs/root". Some *nix systems will use "-" at the end of a file as a backup file (like passwd- would be the last version of the passwd file). I am not positive that is what the "-" at the end is doing in your linked thread, but I don't use it. What you want can be accomplished with one line in your /boot/config/go file: echo "25 * * * * /boot/dyndns.sh" >> /var/spool/cron/crontabs/root
May 27, 201313 yr Author Ok. Thank you for the clarification! And thank you for bringing me to unRAID, I immediatley fell in love with your build when I first saw it on the Newznab Forums. After reading about unRAID it was a matter of mere days before I decided to build myself a Server aswell....
May 27, 201313 yr Welcome to unRAID! I love my server (the great deal on the price & how well unRAID runs on it). I think you will be very happy with your decision to build your own. Glad I could help (bringing you to unRAID & with this thread).
May 27, 201313 yr Author I am completely happy with my decision! Love playing around with new things. After getting this error message: crond[25752]: unable to exec /usr/sbin/sendmail: cron output for user root /boot/dyndns.sh to /dev/null (which I don´t really get, since I am getting the email-notifications via the SimpleFeatures Plugin just fine) i added >/dev/null to the go file, hopefully disabling email notifications (i dont want them anyway, at least for the crontab) turning the go file now into: echo "25 * * * * /boot/dyndns.sh >/dev/null" >> /var/spool/cron/crontabs/root This is supposed to ignore stdout and only send warnings and errors to my mailaccount. Right? Shouldn´t there be some output in /var/log/cron? The log is empty....
June 24, 201313 yr Shouldn´t there be some output in /var/log/cron? The log is empty.... I'd like to know this as well, should I expect any output in /var/log/cron or /var/log/syslog when my scripts from for example /etc/cron.weekly are executed?
June 24, 201313 yr To totally ignore stdout and stderr in cron jobs echo "25 * * * * /boot/dyndns.sh >/dev/null 2>&1 " To direct all cron job output to syslog you can use the following example (which is what I usually use) All output is captured into /var/log/syslog (You'll need to be careful about how much data you output) 25 * * * * /boot/dyndns.sh 2>&1 | /usr/bin/logger -tdyndns.sh[$$]
June 24, 201313 yr I am completely happy with my decision! Love playing around with new things. After getting this error message: crond[25752]: unable to exec /usr/sbin/sendmail: cron output for user root /boot/dyndns.sh to /dev/null (which I don´t really get, since I am getting the email-notifications via the SimpleFeatures Plugin just fine) i added >/dev/null to the go file, hopefully disabling email notifications (i dont want them anyway, at least for the crontab) turning the go file now into: echo "25 * * * * /boot/dyndns.sh >/dev/null" >> /var/spool/cron/crontabs/root This is supposed to ignore stdout and only send warnings and errors to my mailaccount. Right? Shouldn´t there be some output in /var/log/cron? The log is empty.... unfortunately, SimpleFeatures does not install "sendmail, nor any "mail" command that will forward mail sent to "root" onward. The "cron" command sends all output from invoked commands through the "mail" command to the "root" user. Joe L.
June 24, 201313 yr Author I see, thanks for the info. But as long as I can see the output in the syslog I am happy!
Archived
This topic is now archived and is closed to further replies.