Hi, I had a previous question about cron job of q script with timer (can’t see the non-published group email.)
it seems I figured out–the way I was able to keep the q process keep running when starting from cron was to add a port number. Hmm… not sure why? (did I miss this note…?)
thanks
mklee1
June 19, 2021, 2:40pm
2
A q session would keep running if u didn’t call exit or //
Assigning port or not doesn’t matter
Hello Angela,
In your cronjob, you can start a script like;
0 12 * * * sh /<path-to-your-script>/<your-script>.sh >> <path-to-your-output-log>/cronout.log 2>&1 &
Then in this script file you can go with something like this;
#!/usr/bin/env bash . <any-source-or-config-file-you-need-in-your-q-process> cd <to-your-q-script-folder> /home/<your-user>/q/l64/q <your-q-script>.q > <your-log-file-location>_$(date +‘%Y.%m.%dT%H:%M:%S’).log 2>&1 &
Notice the ampersand at the end; that ampersand will keep your process alive until you explicitly call exit in your q script.
Hope this helps.
I think q with port number keeps main execution sequence/thread alive and timer task which has to run different thread must need main.