Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Please help with go-script and cron

Featured Replies

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 :D

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).

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.

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

  • 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.  :D

After reading about unRAID it was a matter of mere days before I decided to build myself a Server aswell....

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).

  • 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....

  • 4 weeks later...

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?

 

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[$$]

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.

  • 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.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.