PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, May 14, 2022

[FIXED] How to run python script in linux terminal console and continue using command line?

 May 14, 2022     command-line, linux, python, ubuntu     No comments   

Issue

My question seems to be quite easy, but for some reason I did not find a quick answer to it. I have a python script that I want to run on the terminal command line (Ubuntu linux server), which works for me. But then I can't use the command line until the script ends. The script takes a long time to run, and I would like to continue using the command line to perform other tasks. How can you do the work of a script when its progress is not shown on the command line, but keep its work? And how can I see the active processes that are running on the server to see if a process is running?

Run script command: python script.py

Add next with & echo "123":

enter image description here


Solution

The script takes a long time to run, and I would like to continue using the command line to perform other tasks.

It seems that you want to run said process in background, please try pasting following

python script.py &
echo "123"

it should start your script.py and then output 123 (without waiting until script.py ends)

how can I see the active processes that are running on the server to see if a process is running?

Using ps command

ps -ef

will list all processes which you would probably want to filter to get interested one to you.



Answered By - Daweo
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing