# Question about .gmt/session folder

**URL:** <https://forum.generic-mapping-tools.org/t/question-about-gmt-session-folder/2436>\
**Category:** PyGMT Q&A\
**Tags:** gmt\
**Created:** [December 11, 2021, 3:48am UTC](https://forum.generic-mapping-tools.org/t/question-about-gmt-session-folder/2436 "2021-12-11T03:48:18Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdtanker](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mdtanker/32/1184_2.png) [@mdtanker](https://forum.generic-mapping-tools.org/u/mdtanker)\
**Post date:** [December 11, 2021, 3:48am UTC](https://forum.generic-mapping-tools.org/t/question-about-gmt-session-folder/2436/1 "2021-12-11T03:48:18Z")

</div>

I was trying to clear some space on my Windows computer and found the following folder C:\Users\matthewt.gmt\sessions which contains \>8Gb of folders such as “gmt\_session.20432”. I assume these were records of each session I’ve run in PyGMT or GMT. Are they necessary to keep? What is their purpose? If they aren’t necessary, is there someway to disable to automatic build up of them?  
Thanks in advance,  
Matt

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [December 11, 2021, 4:13am UTC](https://forum.generic-mapping-tools.org/t/question-about-gmt-session-folder/2436/2 "2021-12-11T04:13:07Z")

</div>

That is odd. GMT normally deletes the session subduers when a session completes. In PyGMT I think that is after each module run. So either something is crashing all the time or there is a problem we would need to look into. For the command line GMT we run `gmt clear sessions`. Not sure if there is a pyGMT equivalent - others can comment on this.

You can certainly delete the entire session directory and its contents. Then run a very simple pyGMT command and examine if it leave behind a subdirectories.

---

<div class="post-metadata">

**Author:** ![mdtanker](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mdtanker/32/1184_2.png) [@mdtanker](https://forum.generic-mapping-tools.org/u/mdtanker)\
**Post date:** [December 11, 2021, 4:59am UTC](https://forum.generic-mapping-tools.org/t/question-about-gmt-session-folder/2436/3 "2021-12-11T04:59:47Z")

</div>

Thanks for the quick reply. I just deleted everything, ran a pyGMT script, and another folder was created. I’m not too worried, for now I’ll just occasionally clear out that folder.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [December 11, 2021, 6:32pm UTC](https://forum.generic-mapping-tools.org/t/question-about-gmt-session-folder/2436/4 "2021-12-11T18:32:19Z")

</div>

Pity that you had no time to tell us what was inside that directory that took 8 GB. That is most strange. Every time a modern script is run (and PyGMT always uses modern mode) a temporary dir is created under _cache_ and there is no way to disable it. And, although it hosts a certain number of temporary files, the only potentially big one is the postscript file. But no way it is conceivable that it can go, not even by far, to 8 GB.

---

<div class="post-metadata">

**Author:** ![mdtanker](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mdtanker/32/1184_2.png) [@mdtanker](https://forum.generic-mapping-tools.org/u/mdtanker)\
**Post date:** [December 11, 2021, 7:09pm UTC](https://forum.generic-mapping-tools.org/t/question-about-gmt-session-folder/2436/5 "2021-12-11T19:09:11Z")

</div>

Yeah, I should have looked before deleting. Looking at the folder created yesterday after running a simple figure script, the folder create in /session is 116 KB, and 110KB of that is “gmt\_1.ps-”. If this was a much more complicated figure and guess each file could start adding up.

Maybe @weiji14 can weigh in, but I’m guessing this has something to do with my gswin issue, similar to this: [https://github.com/GenericMappingTools/pygmt/issues/829](https://github.com/GenericMappingTools/pygmt/issues/829).

To fix the gswin issue earlier I downloaded a gswin.exe and that seemed to fix most issues, but still every time I use fig.show() I get the following error message, but figures still appear fine:

“psconvert [ERROR]: Registry registered C:\Program Files (x86)\GPLGS\gswin32c.exe does not exist. Resorting to the one provided in GMT.”

I’ll be out of communication for the next ~2months so sorry if I don’t reply. Cheers!

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [December 12, 2021, 6:27pm UTC](https://forum.generic-mapping-tools.org/t/question-about-gmt-session-folder/2436/6 "2021-12-12T18:27:27Z")

</div>

I have the same issue. On my windows PC (with GMT 6.3) I have 73 folders (and 465 files) with a total size of 3.2 GB. Some are named gmt\_session\_number and other gmt6\_number. I haven’t delete them.

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [December 12, 2021, 6:41pm UTC](https://forum.generic-mapping-tools.org/t/question-about-gmt-session-folder/2436/7 "2021-12-12T18:41:34Z")

</div>

Can you check when is the oldest folder? Also, I assume these only have PostScript files and possiblly gmt.conf|history stuff? Clearly, the removal of these is failing for some on Windows, but not for @Joaquim on Windows?

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [December 12, 2021, 6:58pm UTC](https://forum.generic-mapping-tools.org/t/question-about-gmt-session-folder/2436/8 "2021-12-12T18:58:24Z")

</div>

The gmt6 files are from Nov-2019 to Jul-2020. The gmt\_sessions files are from this year (July to Nov).

The files are gmt.\* (.canvas .conf .cpt .frame .history .layers.0 .session) which do not exceed 2 KB.  
Also there some \*.ps- files of some 10- or 100- KB. Rarely a found some bigger eps. There is sometimes some .eps or ps- of some MB. There sr one of 548 MB!! Probably something that went wrong.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [December 12, 2021, 8:51pm UTC](https://forum.generic-mapping-tools.org/t/question-about-gmt-session-folder/2436/9 "2021-12-12T20:51:40Z")

</div>

Joaquim uses Julia. And with the Julia wrapper one can almost forget about modern _vs_ classic mode since _classic_ on Julia is almost like _modern_ on CLI. But besides that, GMT.jl when it starts automatically cleans sessions files older then a couple of hours.

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [December 12, 2021, 11:42pm UTC](https://forum.generic-mapping-tools.org/t/question-about-gmt-session-folder/2436/10 "2021-12-12T23:42:28Z")

</div>

True, but since you are skilled in debugging, might you find a clue as to why the the gmt\_manage\_workflow call in end.c does not do what we tell it to?

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [December 13, 2021, 11:17am UTC](https://forum.generic-mapping-tools.org/t/question-about-gmt-session-folder/2436/11 "2021-12-13T11:17:25Z")

</div>

I think those are leftovers files of cases when the script was interrupted before ending and at that time the automatic cleaning for these situations was not working. The sessions dir is now always clean.

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [December 13, 2021, 7:32pm UTC](https://forum.generic-mapping-tools.org/t/question-about-gmt-session-folder/2436/12 "2021-12-13T19:32:41Z")

</div>

I have been hesitant to add an auto cleaning as I currently have a GMT process that has run for 5 weeks…  
But, I think the solution to this is to find the list of PID embedded in those directories and see if such a process exists (via getpgid) and if no such process then we delete that dir. That should be foolproof and could be done by gmt end.
