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.

Schedule a Job

Featured Replies

What is the best way to schedule a job to run at a particular time?  I've been running an rsync client for months now by copying the script to the cron.daily folder from my go script.  That's worked great, but now I want to add another rsync client job to run daily.  The way I figure it if I place the second script in the cron.daily folder they will both run at exactly the same time (4:30am, I think).  What I want to do is stagger the two jobs.  From what I can tell I can edit the 'root' file in the /var/spool/cron/crontabs directory to accomplish this, but I really don't want to muck with my default installation files.  Can I just add my own file to the /var/spool/cron/crontabs directory ?

The way I figure it if I place the second script in the cron.daily folder they will both run at exactly the same time (4:30am, I think).

 

files in /etc/cron.day are usually run one at a time.

That is... as long as the individual job file in the directory does not run commands in the background with an & sign.

 

If you do a crontab -l you will see a bunch of lines with /usr/bin/run-parts.

This is how files in the /etc/cron.xxxxxx directories are processed.

 

you can also place your own job to run via cron. I'll try to find an example. I think there are some on the board.

  • Author

Hmmmm...

 

If I understand this part correctly:

 

# Append new entries to root's crontable

cat <<-EOF >> /tmp/crontab.root

# Daily Automatic /sbin/powerdown

00 23 * * * /sbin/powerdown

EOF

 

You are listing the contents of /tmp/crontab.root to a file of the same name (overwriting the original) and keeping it open for additional input until an "EOF" is read?  The net result is a /tmp/crontab.root file that is the same as the original plus however many additional lines you wanted to add (in this case one additional line).  I'm just trying to follow/understand before I go mucking things up.  I've used the cat command many times before but I don't understand the syntax of "<<-EOF >>"

 

crontab -u root -l | grep -v /sbin/powerdown > /tmp/crontab.root

 

list the contents (-l) of user root ( -u root ) to the input of grep (-v except the line /sbin/powerdown) to a file /tmp/crontab.root

 

cat <<-EOF

EOF

 

Means read stdin from the next lines HERE until you reach a Line with EOF

 

>> /tmp/crontab.root

 

means append the output of something to a file called /tmp/root.crontab.

 

 

so I am reading lines from via stdin in the current document until EOF (cat copies files from stdin to stdout) and appending to the pre-existing file /tmp/crontab.root

 

so a

cat <<-EOF >> /tmp/crontab.root

EOF

 

concatenate lines from stdin here until EOF appending to /tmp/crontab.root.

 

It could have been done with...

 

echo "# Daily Automatic /sbin/powerdown" >> /tmp/crontab.root

echo "00 23 * * * /sbin/powerdown" >> /tmp/crontab.root

 

The net effect is the same.

 

The difference is that by doing it in the here document with one output redirection, the output file iis only opened once.

It also makes adding lines easier. Just insert in between the cat and the EOF.

 

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.