0

OS: Centos 7 | Shell: Bash | Virtual Machine: Virtualbox

I have created a short script to check few servers on startup of my application and need to run this on every reboot.

I have configured the crontab to run it every reboot however i am not seeing the output on the shell.

@reboot /home/admin/scripts/connection.sh

What am i missing in setting this up ?

  • ... why would cron's output show in your shell? – muru Apr 10 '18 at 6:35
  • I wasn't sure it would or not! How can i run this to show once i login on the system ? – Atul Apr 10 '18 at 6:36
2

A cronjob's output does not go to the shell. Most often, the output written to its standard output and standard error streams are collected and mailed to the owner of the cronjob.

To log the output to a file:

@reboot /home/admin/scripts/connection.sh >>/home/admin/connection.log 2>&1

This will make all output from the script be appended to the file /home/admin/connection.log.

  • Hi Kusalananda, Thank you! I will try your suggestion, for the time i added the script to the bashrc and it worked. Appreciate the response! – Atul Apr 10 '18 at 6:50
  • 1
    @Atul Adding the script to the ~/.bashrc file will make it run for once each new shell session (i.e. twice if your open two terminals). – Kusalananda Apr 10 '18 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.