Error Invalid tab id 1 when running as a cron job

When I run a script using a cron job ( it is a desktop automation script), sometimes I get this error
Error Invalid tab id : 1

This occurs usually when I run the script first time during the day using a cron. When I run it again using cron, it works fine.

Can someone tell me what am I doing wrong?


This indicates that your system is a “little bit” slow, and there is a timing issue when starting the browser the first time. I assume that at your 2nd (etc) call the browser is already running, and thus all works well.

=> Workaround: Start browser first, and then the RPA command line

I do not understand your solution. Let me explain what I am doing.
I am running the following shell script on Ubuntu Linux via a cron job

/usr/bin/firefox “file:///root/Downloads/desktop.html?direct=1&macro=skype” &
sleep 60
/usr/bin/killall firefox

Now, skype is the name of the macro. The first line of the macro is
XRun /root/

And is
/usr/bin/skypeforlinux &

Now, what do you want me to do?
How can I just run firefox without the url that contains the skype macro?

If I just run firefox, pause, and then again run firefox with skype macro in the url, I will get the error message saying “firefox is already running. Close it.”

I hope you understand my problem. So, how can I start the browser first, and then the RPA command line?


I confirmed the issue with launching Firefox is Firefox is already open. Chrome does not show this issue. So one solution is to use Chrome.

If you want to work with Firefox, I found that using wdg-open for the first launch solves the issue. (I am not sure why this works/what makes the difference here, if anyone knows, please let us know)

Here is a video of the test. First I run the normal script twice, and then the one that first opens Firefox, then runs the command line. What also helps on slow machines is to add continueInLastUsedTab=0 - With 0 it avoids the tab switching, which can also cause a timing issue (and then we get Invalid tab id).


# Clean up left-overs before start
/usr/bin/killall firefox

# start Firefox first. Any URL can be used. This is for slow systems
xdg-open ""

sleep 5s #Give the browser enough time to fully open

#Now run the actual RPA command line URL
/usr/bin/firefox "file:///home/m/Desktop/"