Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should linux cron jobs be specified with an "&" to indicate to run in background? [closed]

Tags:

linux

cron

In a crontab file, should commands be specified with a trailing "&", or will the command run in the background anyway?

I have:

*/20 * * * * /home/me/monitor/check.sh /home/me/monitor/check.properties  >> /home/me/monitor/check.log 2>&1 & 

I've seen contradictory answers to this question in various places. Some say no need to put an "&", others that without the ampersand cron waits for output from the command, even though all output is redirected.

like image 957
user265330 Avatar asked May 08 '12 17:05

user265330


People also ask

What is the use of * * * * * In cron?

It is a wildcard for every part of the cron schedule expression. So * * * * * means every minute of every hour of every day of every month and every day of the week .

How do I run a cron job in Linux?

Use the crontab -e command to open your user account's crontab file. Commands in this file run with your user account's permissions. If you want a command to run with system permissions, use the sudo crontab -e command to open the root account's crontab file.

Can you have blank lines in crontab?

In a crontab file, blank lines or lines starting with # , spaces or tabs will be ignored.


1 Answers

Every job that's run by cron is run in the background automatically, so no need for the &

See this too.

like image 140
Levon Avatar answered Sep 20 '22 16:09

Levon