Minecraft is not enouth realistic and this command is for realistic trees .
So you just get a command block ( /give @p minecraft:command_block ) and you copy the command.
Then the command need to be in "repeat" then on "unconditional" then in "always active".
And you activate it.
If you want the leaves break too ,search on "realistic tree (leaves)".
Sorry if it's only work on oak , if you want to do it whith an other type ,replace the "log 0 fil..." by an other number.