Ask Your Question

How can I stop sagemath program without quitting sage session?

asked 2017-02-16 09:59:25 +0200

prosolver gravatar image

Hello. First of all, I think it is good to describe how I use SageMath before asking the question.

I installed SageMath in my laptop using Ubuntu 16.04. It is installed in directory "~/sage". I usually run SageMath in terminal. That is, I follow the following steps to run SageMath.

  1. Open the terminal (It is the basic terminal from Ubuntu 16.04).
  2. Go to the directory where SageMath is installed by typing "cd sage".
  3. Type "./sage". Then, sage session begins.

In sage session, I usually load a sage file which I already wrote and run it to check the result. But sometimes, a program does not seem to finish, since computation takes a lot of time. Then, I would like to finish the program which I am running now, but without going out of sage session, since otherwise, I should follow 3 steps above again. However, I could not find how to do it, yet.

Can anybody teach me how to do it?

edit retag flag offensive close merge delete



To cancel the current calculation, hit control-c. Does that do what you want?

John Palmieri gravatar imageJohn Palmieri ( 2017-02-16 19:15:44 +0200 )edit

Thank you! It works! I did not know that there is such a simple solution.

prosolver gravatar imageprosolver ( 2017-02-17 07:02:32 +0200 )edit

Well, sometimes control-c in a terminal terminates the sage session as well (with "core dumped"). In my experience, interrupting the Jupyter kernel has not this drawback.

eric_g gravatar imageeric_g ( 2017-02-18 10:51:34 +0200 )edit

@eric_g: this usually indicates a bug: a core dump should not happen. If it is repeatable, or at least somewhat repeatable, you should report the issue so it can be fixed.

John Palmieri gravatar imageJohn Palmieri ( 2017-02-24 17:00:46 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-02-16 11:14:47 +0200

eric_g gravatar image

I don't know how to do this in a terminal, but if you run SageMath in a Jupyter notebook (i.e. use ./sage -n jupyter), you can stop the execution of the code and keep your session by selecting Interrupt in the Kernel menu.

edit flag offensive delete link more


I haven't used a Jupyter notebook yet, but it seems that it is a good way to use SageMath. I will try.

Thank you for your answer!

prosolver gravatar imageprosolver ( 2017-02-17 07:03:34 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-02-16 09:59:25 +0200

Seen: 3,720 times

Last updated: Feb 16 '17