Programmatically restart julia

I am creating a set of independent scripts for illustrating some concepts and I want to be sure that each of them starts “clean”.
Performance is not a matter, how can I put something at the beginning of each script to force restart of the julia process ?

I have tested this code:

function workspace()
    atexit() do

However while it works on the REPL, it freeze on VSCode…

This one seems to work but it actually doesn’t:

run(`$(Base.julia_cmd()) -e "println(\"Starting this script from a new, clean session\")"`) 

Turn your scripts into functions (or modules). That way they get their own namespace, which should solve any problem you have from an unclean environment, as well as improve performance generally.

If they are truly independent scripts, and you truly don’t care how long they take to run, you could run them through julia filename.jl from the terminal.

Yes, this is the way I use for running the documentation of my packages in github CI, but here I have students that need to manually run these scripts and I could just say them “run this script in a new Julia session” but I would like to have something on the top of the script they can click and run, even if they don’t get the full meaning, but I am sure then they don’t have garbage left from previous lessons (scripts)…

How about “Call this function”?