Script to check if there is an ICA session running for Citrix XenDesktop on IGEL OS every 15 minutes?

We are planning to deploy some clinical autologon iGEL devices, the idea is to have these IGEL devices to autologon to a XenDesktop desktop pool (this is working so far). The IGEL TC need to be autologed on a W10 VD and they shouldn’t be at the iGel desktop, if they are NOT we are looking for a way to send email alert to a distribution list for them to check providing the name of the thin client (hostname).

From one of you scripts I could use this, however is there a way to check if there is an ICA session running for XenDesktop / sessions rather than VMWare? Also could you help to modify the code to send an email if there are not ICA sessions – we will be using an external SMTP relay server – using sender to receipient

Would it be possible to re-run the script every 15 minutes?

Thank you so much! 🙂


systemd-run –unit=”update-script” –on-calendar=”Tue -*- 01:00:00″ /wfs/updatescript

cat <<“EOF” > /wfs/updatescript


RETRIES=9 #Here you can change how many update retries the script will do.

WAIT=30m #Here you can change how long the script will wait after every retry. Please add the suffix ‘s’ for seconds, ‘m’ for minutes, ‘h’ for hours or ‘d’ for days.

#Logging action


#output to systemlog with ID amd tag

LOGGER=”logger -it ${ACTION}”

#Starting update script

echo “Starting” | $LOGGER

#start retry loop

until [ $RETRIES -lt 0 ]; do

#check if session is active

if ! pgrep -x “vmware-remotemk” > /dev/null && ! pgrep -x “wfica” > /dev/null


—– email to using sender to receipient


It looks like that script already checks for XenDesktop sessions; it’s in the ‘pgrep wfica’ part. I’m not sure about the email part… sendmail is a common S.M.T.P. program that is often built-in, but from my quick check, I didn’t see any S.M.T.P. programs on an Igel thin client. It might be possible to add it as a custom partition, but there might be a better option. For running it periodically, you could use cron or a systemd timer, or just use a ‘while $true’ loop with a ~15-minute pause inside the script.

Thanks Jeremy. I don’t know much about scripting with this language just basics. So the following line if ! pgrep -x “vmware-remotemk” > /dev/null && ! pgrep -x “wfica” > /dev/null checks for both VMWare or XenDesktop? I only need to check XD sessions, how can I check only for XD sessions? Can you schedule the script to run every 15 min on all the thin clients via UMS policy?

if ! pgrep wfica; then echo Hello; fi

That will print Hello if wfica isn’t running (wfica is the Citrix Receiver/Workspace Application process)

I have a script running under the user account that is configured to ‘autostart’ as a custom application.

If you want to run it as root, then you can make it a systemd service or timer. Here is a short example that doesn’t actually do anything. 🙂

cat <<“EOF” > /usr/local/bin/


# Put your script here.


chmod +x /usr/local/bin/

cat <<“EOF” > /etc/systemd/system/check-UMS.service




systemctl start check-UMS

All that goes into a ‘Base’ ‘Custom command’.

Hopefully that makes sense…. the first part is the script that you would want to run, like what you posted. You can probably just put it into a ‘while’ loop and put ‘sleep 900’ at the end (to pause for 15 minutes). The second ‘cat << EOF…’ part is to make the systemd service, and the final line starts the systemd service, which runs the script.

Continue reading and comment on the thread ‘Script to check if there is an ICA session running for Citrix XenDesktop on IGEL OS every 15 minutes?’.  Not a member? Join Here!

Learn more, search the IGEL Knowledge Base

Ask a question or comment on the above messasge thread?

Join or log in to the IGEL Community to ask us anything and meet other IGEL customers, partners, and EUC enthusiasts.

Submit a question, or Join Today!

Popular Message Threads

Categories & Tags: