There are two ways to merge duplicate entities without manual intervention. That we can schedule the duplicate detection process and the system will merge those records automatically.
Standard Method:
Scheduling a Mass update: List > Mass Update > Mass Updates > Duplicate Resolution.
Then we can set criteria accordingly and schedule this to run at a particular time.

Scripting Solution:
In case the logic to detect the duplicates is complex or needs that to run in real-time ( also scheduled) we can use the following task module
//Add additional code
...
var dedupeTask = task.create({taskType: task.TaskType.ENTITY_DEDUPLICATION});
dedupeTask.entityType = task.DedupeEntityType.CUSTOMER;
dedupeTask.dedupeMode = task.DedupeMode.MERGE;
dedupeTask.masterSelectionMode = task.MasterSelectionMode.MOST_RECENT_ACTIVITY;
dedupeTask.recordIds = ['107', '110'];
var dedupeTaskId = dedupeTask.submit();
...
//Add additional code