Showing results for 
Search instead for 
Did you mean: 

Cron.d and Email

New Member

Cron.d and Email

I have a linux box trying with a script that runs a report, creates a log then emails it.
Sendmail appears to be working fine as I can run simple "mail" commands and get emails. I have another perl script that emails and it works fine. I did not create either but inherited them.

I simply added a 0, and ,20 to get to 0.7,19,20 hours added the to emails

The Cron.d job is located in the following location and rights.
[admin@RM1CS0AH0368 ~]$ cd /etc/cron.d
[admin@RM1CS0AH0368 cron.d]$ ll
total 4
lrwxrwxrwx 1 root root 24 Apr 30 12:45 nas_sys -> /nas/site/cron.d/nas_sys
lrwxrwxrwx 1 root root 25 Apr 30 12:45 nas_user -> /nas/site/cron.d/nas_user
-rw-r--r-- 1 root root 188 Apr 7 2006 sysstat

The nas_user file is as follows:
[root@RM1CS0AH0368 cron.d]# cat nas_user
0 0 * * 0 nasadmin /nas/bin/server_date server_2 timezone -name America/Chicago >&/dev/null
0 0 * * 0 nasadmin /nas/bin/server_date server_3 timezone -name America/Chicago >&/dev/null
0 0 * * 0 nasadmin /nas/bin/server_date server_4 timezone -name America/Chicago >&/dev/null
20 7,19 * * * nasadmin /home/nasadmin/email/savvol_email 90 >/home/nasadmin/email/sv_cron.log 2>&1
30 0,7,19,20 * * * nasadmin /home/nasadmin/email/repreport|/usr/sbin/sendmail -t >/home/nasadmin/email/repreport.log 2>&1

The script file is located in /home/nasadmin/email

repreport which has the following Contents:

printf "%s\n%s\n\n" "" "Subject:REP RM1 LONG FS Flight Status";
export NAS_DB=/nas;
/nas/bin/nas_replicate -i -a

Here is my question: if I edit the file under the folder /etc/cron.d/nas_user, do I have to restart the crond daemon?

/sbin/service crond restart

Also, what is the printf "%s\n%s\n\n" saying?
Honored Contributor

Re: Cron.d and Email

> [...] a linux box [...]

Not a very detailed description of anything.

> [...] if I edit the file under the folder
> /etc/cron.d/nas_user, do I have to restart
> the crond daemon?

man cron
man crontab

On many UNIX systems, an advantage of using
"crontab -e" is that the "cron" daemon gets
notified that the file has been changed, so
it must be re-read. If you edit one of these
files behind its back, then _you_ need to
tell the "cron" daemon to re-read its
configuration files. A complete re-start
should do it, but a less brutal method, like,
say "kill -HUP" may also do it.

On my Debian system, however, "man cron"

Additionally, cron checks each minute to see if its spool directory's
modtime (or the modtime on /etc/crontab) has changed, and if it has,
cron will then examine the modtime on all crontabs and reload those
which have changed. Thus cron need not be restarted whenever a crontab
file is modified. Note that the crontab(1) command updates the modtime
of the spool directory whenever it changes a crontab.

which makes it sound as if it's all pretty
Trusted Contributor

Re: Cron.d and Email

> Also, what is the printf "%s\n%s\n\n" saying?

The printf command lets you specify formatting and other options in a standard way (it follows the C printf command.)

What the above will do is print a string argument (%s), followed by a newline (\n), then a second string argument (%s) then two newlines (\n\n). Given the whole line, it should look like this (assuming the forum retains my spacing:
Subject:REP RM1 LONG FS Flight Status

<"then it will insert the output of nas_replicate -i -a">

This follows the RFC822 specification for email messages, so that the command output will land in the body of the email.
New Member

Re: Cron.d and Email

Thanks I will work with this information to see if I can get head way. I appreciate the info.