How can I execute a Tasker reboot command only 1 time? I'm working with a chinese tablet which needs to be initialized every time after it's connected to a power source.

I'm using Tasker to do so.
Problem is: this condition makes tasker execute the reboot command over and over, and it becomes a bootloop.

What should I do in order to initialize the tablet when a power source is attached, but avoid it from entering the bootloop?

Edit: TaskerProfile

&lt;TaskerData sr="" dvi="1" tv="4.6u3"&gt;
&lt;Profile sr="prof2" ve="2"&gt;
&lt;cdate&gt;1431370575080&lt;/cdate&gt;
&lt;edate&gt;1431372456863&lt;/edate&gt;
&lt;id&gt;2&lt;/id&gt;
&lt;mid0&gt;4&lt;/mid0&gt;
&lt;State sr="con0" ve="2"&gt;
&lt;code&gt;10&lt;/code&gt;
&lt;pin&gt;true&lt;/pin&gt;
&lt;Int sr="arg0" val="1"/&gt;
&lt;/State&gt;
&lt;/Profile&gt;
&lt;Profile sr="prof5" ve="2"&gt;
&lt;cdate&gt;1431370730220&lt;/cdate&gt;
&lt;edate&gt;1431371684461&lt;/edate&gt;
&lt;flags&gt;2&lt;/flags&gt;
&lt;id&gt;5&lt;/id&gt;
&lt;mid0&gt;6&lt;/mid0&gt;
&lt;State sr="con0" ve="2"&gt;
&lt;code&gt;10&lt;/code&gt;
&lt;Int sr="arg0" val="1"/&gt;
&lt;/State&gt;
&lt;/Profile&gt;
&lt;Project sr="proj0" ve="2"&gt;
&lt;cdate&gt;1431027887676&lt;/cdate&gt;
&lt;mdate&gt;1431371133517&lt;/mdate&gt;
&lt;name&gt;Base&lt;/name&gt;
&lt;pids&gt;2,5&lt;/pids&gt;
&lt;tids&gt;4,6,7&lt;/tids&gt;
&lt;Img sr="icon" ve="2"&gt;
&lt;nme&gt;hl_aaa_ext_home&lt;/nme&gt;
&lt;/Img&gt;
&lt;/Project&gt;
&lt;Task sr="task4"&gt;
&lt;cdate&gt;1431370589904&lt;/cdate&gt;
&lt;edate&gt;1431372085383&lt;/edate&gt;
&lt;id&gt;4&lt;/id&gt;
&lt;nme&gt;Task1&lt;/nme&gt;
&lt;pri&gt;10&lt;/pri&gt;
&lt;Action sr="act0" ve="7"&gt;
&lt;code&gt;410&lt;/code&gt;
&lt;Str sr="arg0" ve="3"&gt;Documents/sdcard.txt&lt;/Str&gt;
&lt;Str sr="arg1" ve="3"&gt;0&lt;/Str&gt;
&lt;Int sr="arg2" val="0"/&gt;
&lt;Int sr="arg3" val="0"/&gt;
&lt;/Action&gt;
&lt;/Task&gt;
&lt;Task sr="task6"&gt;
&lt;cdate&gt;1431370741046&lt;/cdate&gt;
&lt;edate&gt;1431372415674&lt;/edate&gt;
&lt;id&gt;6&lt;/id&gt;
&lt;nme&gt;Task2&lt;/nme&gt;
&lt;pri&gt;10&lt;/pri&gt;
&lt;Action sr="act0" ve="7"&gt;
&lt;code&gt;417&lt;/code&gt;
&lt;Str sr="arg0" ve="3"&gt;Documents/sdcard.txt&lt;/Str&gt;
&lt;Str sr="arg1" ve="3"&gt;%True&lt;/Str&gt;
&lt;/Action&gt;
&lt;Action sr="act1" ve="7"&gt;
&lt;code&gt;410&lt;/code&gt;
&lt;Str sr="arg0" ve="3"&gt;Documents/sdcard.txt&lt;/Str&gt;
&lt;Str sr="arg1" ve="3"&gt;1&lt;/Str&gt;
&lt;Int sr="arg2" val="0"/&gt;
&lt;Int sr="arg3" val="0"/&gt;
&lt;ConditionList sr="if"&gt;
&lt;Condition sr="c0" ve="3"&gt;
&lt;lhs&gt;%True&lt;/lhs&gt;
&lt;op&gt;2&lt;/op&gt;
&lt;rhs&gt;0&lt;/rhs&gt;
&lt;/Condition&gt;
&lt;/ConditionList&gt;
&lt;/Action&gt;
&lt;/Task&gt;
&lt;Task sr="task7"&gt;
&lt;cdate&gt;1431371028431&lt;/cdate&gt;
&lt;edate&gt;1431372348654&lt;/edate&gt;
&lt;id&gt;7&lt;/id&gt;
&lt;nme&gt;runshell&lt;/nme&gt;
&lt;pri&gt;10&lt;/pri&gt;
&lt;Action sr="act0" ve="7"&gt;
&lt;code&gt;123&lt;/code&gt;
&lt;Str sr="arg0" ve="3"&gt;reboot&lt;/Str&gt;
&lt;Int sr="arg1" val="0"/&gt;
&lt;Int sr="arg2" val="1"/&gt;
&lt;Str sr="arg3" ve="3"/&gt;
&lt;Str sr="arg4" ve="3"/&gt;
&lt;Str sr="arg5" ve="3"/&gt;
&lt;ConditionList sr="if"&gt;
&lt;Condition sr="c0" ve="3"&gt;
&lt;lhs&gt;%True&lt;/lhs&gt;
&lt;op&gt;2&lt;/op&gt;
&lt;rhs&gt;0&lt;/rhs&gt;
&lt;/Condition&gt;
&lt;/ConditionList&gt;
&lt;/Action&gt;
&lt;/Task&gt;
&lt;/TaskerData&gt;
If I understood the question correctly, you want to connect the device to a power source which triggers Tasker to reboot the device (for initialization). But when the device reboots itself Tasker finds that the power source is connected so it repeats the task again. Your goal is to make Tasker reboot only once while power source remains connected. If the source is to be removed and re-inserted again, then Tasker should do the reboot again only for once.



Based on this understanding, I proposed the following solution:

The solution is very trivial. I'm using two profiles in Tasker, namely:


Not power USB
Power USB


These two profiles, as obvious, will be triggered by connecting/disconnecting the power source to the Android device. I'm using a file's content as a condition here to restrict boot-loop.

Note: For this answer, I chose my power source as USB only. 

Instructions:

Regarding the file content:


Create an empty file in your default storage. (I created a file named sdcard.txt in /sdcard. The location of this file is /sdcard/sdcard.txt.)
Open this file in a text editor in Android and add 0 in it. (I used 920 Text Editor).
Note that there is no logical reasoning in using 0 only. It will be used in a conditional statement only. You're at liberty to try an another number.


Regarding Profiles and Tasks in Tasker app:


Launch Tasker.
Under Profiles tab create a Profile by tapping + &rarr; State &rarr; Power &rarr; Power.
Under Source choose USB.
Check Invert -- this will make Not power USB profile.
Press Back key/button once and select New Task.
Add a name for your task (persistent) or leave it blank (deleting profile will delete it as well). 
Under Tasks tab tap + &rarr; File &rarr; Write File.
Under File field mention the location of your text file. In this case, it is /sdcard/sdcard.txt.
Write 0 under Text field.
Uncheck Append  and Add Newline. -- we want to replace the content, so no appending should be done.
Tap Back key/button twice to save this task.
In order to create Power USB profile, repeat step 2,3,5 and 6, respectively. 
Under Tasks tab tap + &rarr; File &rarr; Read File.
Repeat step 8.
Under To Var type %True -- You can change %True to any other name. Make sure that you capitalize at least one letter of your variable to make it non-local. See this to know more.
Repeat step 11, 7 and 8.
Type 1 under Text field.
Repeat step 10.
Tap + corresponding to If. Add %True and 0 in fields respectively. It should look like %True ~ 0.
Repeat step 11.
Under Tasks tab tap + &rarr; Code &rarr; Run Shell.
Type reboot under Command. (My device is rooted, so I provided root permissions to this step to avoid any hassle.) As a soft-reboot option, you can use killall zygote instead of reboot.
Check Use Root if your device is rooted.
Leave Store Output In and Store Errors In blank.
Repeat step 19 and 20.
Go to Profiles and enable both profiles. To save yourself from unnecessary trouble, disable any other power related profile other than the ones mentioned above.
Tasker must be Enabled. You can check this by tapping Menu key/button once and amongst the options, Disable tasker would be visible. Also, if this app is running and you happen to minimize it, then as a default setting you would see its icon in the Status bar with the profile mentioned there (if activated).


We're good to go. 


Go to Home Screen of your device.
Connect power source (we used USB only here).
Your device will reboot. Do not disconnect power source to verify that boot-loop vanished.
When the device comes back to Home Screen after reboot, you can see that Power USB profile is activated in tasker yet there is no boot-loop, not to mention that your initialization is also done. :)
Disconnect power source and the profile will switch to No power USB.
Connect power source again and device will reboot again for once.


Status: Objective Completed. Done!