Cron: Difference between revisions

imported>Sjau
<code> is easier to spot that <tt>
imported>Sjau
No edit summary
Line 25: Line 25:


The <code>. /etc/profile;</code> part first sources the profile file and hence loading the environment. After that, the actual command is being run in the proper environment. The above entry would run the rss2email program every <code>10 minutes</code> as user <code>johndoe</code>
The <code>. /etc/profile;</code> part first sources the profile file and hence loading the environment. After that, the actual command is being run in the proper environment. The above entry would run the rss2email program every <code>10 minutes</code> as user <code>johndoe</code>
==Send mail only when error==
In case you have set proper sendmail and defined a user where cron should send output to, you might want limit those emails only when cron encounters a problem. This can easily be achieved by storing the output of the command given into a variable and use the <code>||</code> control operator to echo this output only when there is a non-zero exit status of the command.
<syntaxHighlight lang="nix">
      "0 * * * *      hyper  out=$( /run/current-system/sw/bin/pass git pull 2>&1 ) || echo $out"
</syntaxHighlight>


=See also=
=See also=