0

Is there any way that i can auto run a python script at boot and see its output on the terminal other than editing the .bashrc file ?

I tried using crontab job and putting myscript in /etc/init.d/ directory but these two methods require a log file to see the output and that's not what i want.

  • is this a long running script? or just a quick thing to process during startup – Chad G Apr 23 '18 at 16:12
  • it's a quick simple script that prints something – Hbib Apr 23 '18 at 16:17
1

actually, .bashrc won't work to start something on boot. You might try running stuff on /etc/rc.local, that will print output to what you see during boot time. But in order to work "right" your script has to either finish or it has to go into the background. If it hangs forever without letting execution continue, boot sequence won't finish.

Addendum: Real question was related to user login time, not boot time. The answer is to use ~/.profile.

  • Also, I would recommend to use syslog module to send output to syslog. That's way more elegant. – eftshift0 Apr 23 '18 at 16:06
  • /etc/rc.local also doesn't print stuff to the terminal – Hbib Apr 23 '18 at 16:19
  • It does print stuff on the terminal. During boot time you see something about "My IP is blah blah"? That's on rc.local. – eftshift0 Apr 23 '18 at 16:22
  • no actually i don't see that, i log in via putty – Hbib Apr 23 '18 at 16:34
  • putty? ssh? That's certainly not boot time. That's more like user login time. I think you have to try in one of these: ~/.bashrc, ~/.profile – eftshift0 Apr 23 '18 at 16:37

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.