• Status: Solved
  • Priority: High
  • Security: Public
  • Views: 45
  • Last Modified:

cron job run in background by Default

is it possible run cron job not in background ?
Andy Goodarzi
Andy Goodarzi
1 Solution
I think cron jobs are run by the cron daemon, so they won't run in your foreground, but what are you wanting to achieve, exactly?
The use of cron is mainly for background tasks.  You'd have to start a foreground process to bring it forward.

Something along the lines of the following would do it.
0 * * * *  DISPLAY=:0 xterm -e /path/to/script.sh
Andy GoodarziAuthor Commented:
i want to see what happen while my scrip.sh running .
Gerwin Jansen, EE MVETopic Advisor Commented:
>> i want to see what happen while my scrip.sh running .
You can output everything that is done in your script by calling it with the -xv flags and redirecting it's output to a file.

If this is your crontab entry:

0 8 * * * /home/user/scrip.sh

and your shell is sh then change the crontab entry to this:

0 8 * * * /bin/sh -xv /home/user/scrip.sh >> /home/user/scrip.sh.output

When the script has run, check /home/user/scrip.sh.output for what has happened.
Andy GoodarziAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now