Keep Sage running in background linux

asked 2017-06-22 13:37:19 -0500

Andriy gravatar image

updated 2017-06-22 14:34:40 -0500

I need to be able to execute sage commands via the command line without opening the Sage shell. I am currently doing this through "sage -c 'cmd'". The issue I have is that this forces all of sage to boot up, run the command, and then shutdown. Something simple as "sage -c "print(derivative(5*x,x))" takes 3-4 seconds to run. How would I speed this up? My idea was to somehow run Sage in the background and be able to feed it input but I am not sure how to do that. I am feeding the command line input from an external program.

EDIT: I found something that may be useful here: (

The solution this user provides is creating a python socket server to constantly be running sage and pass along input for evaluation into it. The code isn't exactly daemonized so I will attempt to do that later. I will report on if I got it to work.

edit retag flag offensive close merge delete



Having such a daemon for Sage would be very nice. Do not hesitate to share your code when it is working !

tmonteil gravatar imagetmonteil ( 2017-06-23 03:52:14 -0500 )edit